Test instructions
Give 2n player ID, ability value and initial score
Then by the scores from big to small, id from small to large sort
The next player plays
Score +1 with a high capacity value
Carry R Wheel
Q What is the number of the player ID after the game?
Ideas:
Start with sort once, each round of the game is merged
Win a group of people, lose a group of people, to ensure that two groups of orderly
Then merge into the original array
The output will be good after the R wheel.
/************************************************author:d evilcreated TIME:2016/6/10 14:24:16***************** ******************************* */#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<Set>#include<map>#include<string>#include<cmath>#include<stdlib.h>using namespacestd;Const intn=1e5+Ten;intN;structwq{intId,score,cap; voidPushintAintBintc) {ID=A; Score=b; Cap=C; }}eg[n<<1],eg1[n],eg2[n];BOOLCMP (Wq a,wq b) {if(A.score!=b.score)returnA.score>B.score; returna.id<b.id;}voidFun () {intl1=1, l2=1; for(intI=1; i<=n;i+=2) { if(eg[i].cap>eg[i+1].cap| | eg[i].cap==eg[i+1].cap&&eg[i].id<eg[i+1].id) {eg1[l1++].push (eg[i].id,eg[i].score+1, Eg[i].cap); Eg2[l2++]=eg[i+1]; } Else{EG1[L1++].push (eg[i+1].id,eg[i+1].score+1, eg[i+1].cap); Eg2[l2++]=Eg[i]; } } intA=1, b=1, c=1; while(a<l1&&b<L2) { if(eg1[a].score>eg2[b].score| | eg1[a].score==eg2[b].score&&eg1[a].id<eg2[b].id) Eg[c++]=eg1[a++]; Elseeg[c++]=eg2[b++]; } while(A<L1) eg[c++]=eg1[a++]; while(B<L2) eg[c++]=eg2[b++];}intMain () {//freopen ("In.txt", "R", stdin); intt,r,q; scanf ("%d",&t); while(t--) {scanf ("%d%d%d",&n,&r,&q); N<<=1; for(intI=1; i<=n;i++) {scanf ("%d",&Eg[i].score); Eg[i].id=i; } for(intI=1; i<=n;i++) scanf ("%d",&eg[i].cap); Sort (eg+1, eg+n+1, CMP); while(r--) fun (); printf ("%d\n", eg[q].id); } return 0;}
The seventh session of Shandong Province Swiss-system D tournament (merge sort)