Zjut 1330 竞赛排名 请你查错

//http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1330
#include < iostream >
#include
< string >
#include
< vector >
#include
< algorithm >
using namespace std;

struct Player
... {
stringname;
intscore;
}
;

vector
< Player > v;

int findName( string name)
... {
for(inti=0;i<v.size();i++)
if(v[i].name==name)returni;
return-1;
}


bool cmp(Playera,Playerb)
... {
if(a.score==b.score)
returna.name<b.name;
else
returna.score>b.score;
}


void addPlayer( string name, int score)
... {
Playert;
t.name
=name;
t.score
=score;
v.push_back(t);
}


void outputPlayer()
... {
cout
<<1<<":"<<v[0].name;
for(inti=1;i<v.size();i++)
...{
if(v[i].score==v[i-1].score)
...{
cout
<<""<<v[i].name;
}

else
...{
cout
<<endl;
cout
<<i+1<<":"<<v[i].name;
}

}

cout
<<endl;
}


bool run( int now)
... {
intn;
cin
>>n;
if(n==0)returnfalse;
v.clear();

inti,m=n*(n-1)/2;

for(i=0;i<m;i++)
...{
strings,t;
boolf;

cin
>>s>>t>>f;
intj=findName(s);
intk=findName(t);

if(f==true)
...{
if(j==-1)
addPlayer(s,
3);
else
v[j].score
+=3;

if(k==-1)addPlayer(t,0);
}

else
...{
if(j==-1)
addPlayer(s,
1);
else
v[j].score
++;

if(k==-1)
addPlayer(t,
1);
else
v[k].score
++;
}

}


if(n>=2)
...{
sort(v.begin(),v.end(),cmp);
outputPlayer();
}


returntrue;
}


int main()
... {
intnow=1;
while(run(now++));
return0;
}

你可能感兴趣的:(T)