"Problem-solving report" Swiss round (NOIP2011 universal group T3)

Source: Internet
Author: User

"Digression: This problem ..." To be honest, I don't really like ... Because of the card fast row. 】

The topic is not affixed, is to give you a format, and then each player's initial score and ability values, ask you to carry out R wheel after the Q number is how many (this number is to be counted in the Oyz, the initial fast row should also pay attention to. )

I used the more conventional method, each time scanning the entire sequence, calculate the winner and the negative, divide into two arrays, and then merge the two arrays back into the original sequence (because the two sequences are already ordered, so you can eliminate the order of direct merging), the topic requires a small number of rows in front, Because merging is a stable sort, you don't need to worry about that.

In essence, it's a skill simulation, isn't it?

Under the code, the style is still ugly.

#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace Std;
Ifstream fin ("swiss.in");
Ofstream fout ("Swiss.out");
struct per
{
int FS;
int NL;
int BH;
};
Per player[200005];
int rs=0,ls=0,gz=0;
Per winner[100005]={0},loser[100005]={0};
void Heib ();
bool px (per a,per b);
int main (void)
{
fin>>rs>>ls>>gz;
rs*=2;
for (int i=1;i<=rs;i++)
{
fin>>player[i].fs;
Player[i].bh=i;
}
for (int i=1;i<=rs;i++) fin>>player[i].nl;
Sort (player+1,player+rs+1,px);
for (int i=1;i<=ls;i++)
{
for (int j=1;j<=rs;j++)
{
if (j%2==0)
{
if (player[j].bh==127| | player[j-1].bh==127)
{
}
if (player[j].nl>player[j-1].nl)
{
WINNER[J/2].BH=PLAYER[J].BH;
winner[j/2].fs=player[j].fs+1;
winner[j/2].nl=player[j].nl;
LOSER[J/2].BH=PLAYER[J-1].BH;
Loser[j/2].fs=player[j-1].fs;
loser[j/2].nl=player[j-1].nl;
}
Else
{
WINNER[J/2].BH=PLAYER[J-1].BH;
winner[j/2].fs=player[j-1].fs+1;
winner[j/2].nl=player[j-1].nl;
LOSER[J/2].BH=PLAYER[J].BH;
Loser[j/2].fs=player[j].fs;
loser[j/2].nl=player[j].nl;
}
}
}
Heib ();
}
fout<<player[gz].bh;
return 0;
}

bool px (per a,per b)
{
if (A.FS>B.FS) return 1;
if (A.FS==B.FS&&A.BH<B.BH) return 1;
if (A.FS==B.FS&&A.BH>B.BH) return 0;
return 0;
}


void Heib ()
{
int lf=1,rt=1,zz=1;
while (LF&LT;=RS/2&AMP;&AMP;RT&LT;=RS/2)
{
if (winner[lf].fs>loser[rt].fs| | (WINNER[LF].FS==LOSER[RT].FS&AMP;&AMP;WINNER[LF].BH&LT;LOSER[RT].BH))
{
PLAYER[ZZ].BH=WINNER[LF].BH;
Player[zz].fs=winner[lf].fs;
player[zz].nl=winner[lf].nl;
zz++;
lf++;
}
if (winner[lf].fs<loser[rt].fs| | (WINNER[LF].FS==LOSER[RT].FS&AMP;&AMP;WINNER[LF].BH&GT;LOSER[RT].BH))
{
PLAYER[ZZ].BH=LOSER[RT].BH;
Player[zz].fs=loser[rt].fs;
player[zz].nl=loser[rt].nl;
zz++;
rt++;
}
}
while (lf<=rs/2| | RT&LT;=RS/2)
{
if (LF&LT;=RS/2)
{
PLAYER[ZZ].BH=WINNER[LF].BH;
Player[zz].fs=winner[lf].fs;
player[zz].nl=winner[lf].nl;
lf++;
}
if (RT&LT;=RS/2)
{
PLAYER[ZZ].BH=LOSER[RT].BH;
Player[zz].fs=loser[rt].fs;
player[zz].nl=loser[rt].nl;
rt++;
}
zz++;
}
Return
}

Topic 2: In fact, two of the problem-solving report I also a few questions, but are too simple or too disgusting to I do not want to write the solution ... Oyz "

"Digression 3: Here is a quasi-third day dog, after the beginning of the school became the third day dog estimates will not be too soon updated ..."

"Problem-solving report" Swiss round (NOIP2011 universal group T3)

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.