A. Ariel
Time Limit:20 Sec
Memory limit:256 MB
Topic Connection
Http://codeforces.com/gym/100685/problem/A
Description
King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up a swimming competition in the Kingdom merfolk. Thousands of creatures come to take part in competition, that's why it's too difficult to take the first place.
For the King's beloved daughter Ariel this competition was the first in hers life. Ariel is very kind, so she wants to give a lot of gold medals. Ariel says, that's it's unfair to make a single ranking list for creatures that's so different. It's really a good result to being the fastest small fish without tail in merfolk!
Ariel chooses k Important traits (such as size, tailness, rapacity and so on). A creature can either possess a trait or not (there is no intermediate options).
A score is given-creature (it doesn ' t matter how it was calculated) and the list of possessed traits F1, ..., fy is also given.
Ariel wants to know the place occupied by creature a -a competition among creatures, who has the same trai TS h1, ..., ht. So if creature a doesn ' t has a trait hi, then all creatures in the Competi tion is without this trait. If creature a has a trait hi, then all creatures in the competition having T His trait. Other traits doesn ' t matter. The winner of the competition is a creature with the maximum score.
Input
The first line contains n (1≤ n ≤104" and K (1≤ k ≤10). The next n lines contain information about creatures: score (1≤ score ≤109), y ( 0≤ y ≤ k )-the number of possessed traits, and y numbers F i (1≤ F i ≤ k ) -ids of possessed traits. All F I in one line is different.
The next line contains m (1≤ m ≤105)-the number of queries from Ariel. The next m lines describe queries: a (1≤ a ≤ n)-the ID of a Creatur E, then T -the number of traits, then t numbers hI. All hi in one line is different.
Output
For each query, output the place of a creature a in ranking list amount the corresponded creatures. If Several creatures has the same score all of them take the same place.
Sample Input
3 2
100 1 1
50 1 2
30 2 1 2
12
1 2 1 2
1 1 1
1 1 2
1 0
2 0
2 1 1
2 1 2
2 2 2 1
3 0
3 2 1 2
3 1 2
3 1 1
Sample Output
1
1
1
1
2
1
1
1
3
1
2
2
HINT
Test instructions
There are species, up to 10 characters, and have fractions
Then every query, x num hi......hnum
Then ask you to meet this characteristic of the creature, this X's score row
The following:
Direct stupid force is good, do not think more, the question is lazy, the data is water
Code
#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineTest Freopen ("Test.txt", "R", stdin)#defineMAXN 1501#defineMoD 1000000007#defineEPS 1e-9Const intinf=0x3f3f3f3f;Constll infll =0x3f3f3f3f3f3f3f3fll;inline ll Read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//**************************************************************************************Vector<int>G[MAXN];structnode{intx, y;}; Node kiss[200001];intMain () {intN=read (), k=read (); for(intI=0; i<n;i++) {kiss[i+1].x=read (); inttmp=0; intnum=read (); for(intj=0; j<num;j++) { intx=read (); TMP=tmp| (1<< (x1)); } kiss[i+1].y=tmp; G[tmp].push_back (Kiss[i+1].x); } for(intI=0; i<maxn;i++) sort (G[i].begin (), G[i].end ()); intm=read (); for(intI=0; i<m;i++) { intId=read (), num=read (); inttmp=0; for(intj=0; j<num;j++) { intx=read (); TMP=tmp| (1<< (x1)); } intans=0; for(intI=0; i<maxn;i++) if((i&tmp) = = (kiss[id].y&tmp)) Ans+=g[i].size ()-(Upper_bound (G[i].begin (), G[i].end (), kiss[id].x)-G[i].begin ()); printf ("%d\n", ans+1); }}
Codeforces Gym 100685 A. Ariel violence