NOIP201103 Swiss Wheel "B002"

Source: Internet
Author: User

"B002" Swiss Turn "Class B" from the Middle school OJ ——————————————————————————————————————————————————————————————————————————————————————————— ————————————

"Background" in competitive competitions such as table tennis, badminton and chess, the most common format is knockout and round robin. The former is characterized by less than the number of games, each with a tense stimulus, but the contingency is higher. The latter is characterized by fairness and low contingency, but the course of the competition is often lengthy. The Swiss round format, introduced in the subject, was named after the earliest use of the chess competition held in Switzerland in 1895. It can be seen as a compromise between the knockout and the round robin, both to ensure the stability of the game and to keep the fixtures from being too long.
"Problem description" 2*n a player named 1~2n with a total of R-wheel races. Players will be ranked from highest to lowest in each round before the start of the game and after all competitions have been completed. The total score for the player is the initial fraction before the start of the first round plus the scores of all the matches that have been played. With the same total score, the players with the smaller number of contracts are ranked front. The match arrangement for each round is related to the ranking before the start of the competition: 1th and 2nd, 3rd and 4th 、......、 2k–1 and 2nd K 、......、 2n–1 and 2N, each with a match. Each match wins 1 points, the negative 0 points. In other words, other than the first round, the arrangement of the other rounds is not predetermined, but depends on the player's performance in the previous match. Given the initial score of each player and their strength, try to calculate the number of players in Q after the R-round race. We assume that the player's strength is 22 different, and that the high strength of each game always wins.

The first line of the input requirements input is three positive integers n, R, Q, separated by a space for every two numbers, indicating that there are 2*n players, R-wheel races, and the rank Q we care about. The second line is a 2*n non-negative integer s1,s2,... s2n, separated by a space between each two digits, where Si represents the initial score of the contestant numbered I. The third line is a 2*n positive integer w1,w2,..., w2n, separated by a space between each two numbers, where WI represents the strength of the player numbered I.

The output requirement output has only one row and contains an integer, which is the number of the player who ranked Q at the end of the R-round race.

"Input Sample"

2 4 27 6 6 710 5 20 15

"Output Sample"

1

"Other requirements" 1≤n≤100,000,1≤r≤50,1≤q≤2n,0≤s1,s2,..., s2n≤100000000,1≤w1,w2,..., w2n≤100000000.

"topic analysis" A cursory look, a bit like a simulation problem, only need to constantly qsort, but will time out, only need to create a new data structure + optimized sort can be AC

Code

#include <iostream> #include <cstdio> #include <algorithm> using namespace std;  int N,r,q,i,j,ji;  struct node//new data structure, easy to rank {int s,p,ii;    }A[200010],W[100010],L[100010];      BOOL CMP (node A,node b) {if (A.S==B.S) return a.ii<b.ii;  Return a.s>b.s;      } int main () {cin>>n>>r>>q; n*=2;      for (I=1;i<=n;++i) scanf ("%d", &a[i].s), a[i].ii=i;      for (J=1;J&LT;=N;++J) scanf ("%d", &AMP;A[J].P);  Sort (a+1,a+1+n,cmp);//sort first pass ranking for (ji=1;ji<=r;ji++) {int wi=1,lo=1; Victor, loser flag variable initialization for (i=1;i<=n;i+=2) {if (A[I].P&LT;A[I+1].P) w[wi++]=a[i+1],l[lo++]=a  [i];          W[x] refers to the xx people win x times else if (A[I].P&GT;A[I+1].P) l[lo++]=a[i+1],w[wi++]=a[i];        } wi--;          lo--;          for (i=1;i<=n/2;i++) w[i].s++;          int X=1,y=1;          i=0; while (X&LT;=N/2 && y<=n/2) {if (w[x].s>l[y].S) a[++i]=w[x++];              if (W[X].S&LT;L[Y].S) a[++i]=l[y++];              if (w[x].s==l[y].s && W[X].II&GT;L[Y].II) a[++i]=l[y++];           if (w[x].s==l[y].s && W[X].II&LT;L[Y].II) a[++i]=w[x++];                } if (X&GT;N/2) while (Y&LT;=N/2) a[++i]=l[y++];       else while (X&LT;=N/2) a[++i]=w[x++];     } printf ("%d", A[Q].II);     System ("pause");       return 0; }

"Note": The subject has been AC

NOIP201103 Swiss Wheel "B002"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.