1#include <bits/stdc++.h>2 #defineLowbit (x) x& (-X)3 #defineLL Long Long4 #defineN 2000055 #defineM 10000056 #defineMoD 1000000007LL7 #defineINF 0X7FFFFFFFF8 using namespacestd;9InlineintRA ()Ten { One intx=0, f=1;CharCh=GetChar (); A 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; the } -vector<int>Man[n]; - intMx[n],person[n]; - BOOLcmpintAintb) + { - returnmx[a]<Mx[b]; + } A intMain () at { - intn=RA (); - for(intI=1; i<=n; i++) - { - intA=ra (), b=RA (); - Man[a].push_back (b); inmx[a]=b; -person[i]=i; to } +Sort (person+1, person+1+n,cmp); - intq=RA (); the while(q--) * { $ Set<int>leave;Panax Notoginseng intk=RA (); - for(intI=1; i<=k; i++) the { + intt=RA (); A Leave.insert (t); the } + inttmp[2],num=0; -tmp[0]=tmp[1]=0; $ for(intJ=m; i>=1; i--) $ { - if(Leave.count (Person[i]))Continue; -tmp[num++]=Person[i]; the if(num==2) Break; - }Wuyi if(man[tmp[0]].size () = =0) the { -cout<<"0 0"<<Endl; Wu Continue; - } About if(num==2) $ { - intIt=*lower_bound (man[tmp[0]].begin (), man[tmp[0]].end (), mx[tmp[1]]); -printf"%d%d\n", tmp[0],it); - } A Else if(num==1) +printf"%d%d\n", tmp[0],man[tmp[0]][0]); the } - return 0; $ } the //It was embarrassing. At first, I thought we could find the biggest one. 2333 the //Unexpectedly only than the second largest big can, is really mentally retarded. the //The first time you find a vector, you can play with Lower_bound 2333
cf749 d.leaving Auction