本站遷移

因為我最近租用了網路空間以及網域,
故本站已遷移至新網站~
這邊的資訊已經正在進行搬移的工作~
希望各位可以到新網站去逛XD

New Website:
http://knightzone.org/

搜尋此網誌

2011年3月15日 星期二

[UVa]10258:Contest Scoreboard

照著題目說的做即可得解。
要注意,當某題目被AC後,
後面如果同組有再送同樣那題,
就不用再去增加那題的懲罰時間。
(不過個人不確定會不會有這種可能性就是了。)

[C++](0.016)
#include<iostream>
#include<sstream>
using namespace std;
struct Contest{
int id;
int problem[10][2];
int AC;
int time;
bool have;
};
bool cmp( Contest a, Contest b )
{
if( a.AC > b.AC )
return 1;
else if( a.AC == b.AC && a.time < b.time )
return 1;
else if( a.AC == b.AC && a.time == b.time && a.id < b.id )
return 1;
return 0;
}
int main()
{
int N;
while( cin >> N )
{
string s;
stringstream ss;
cin.get();
getline( cin, s );
for( int i = 0 ; i < N ; i++ )
{
if( i )
cout << endl;
int contestant, problem, time;
char L;
Contest team[105];
for( int j = 0 ; j < 105 ; j++ )
{
team[j].id = j;
memset( team[j].problem, 0, sizeof(team[j].problem) );
team[j].AC = 0;
team[j].time = 0;
team[j].have = 0;
}
while( getline( cin, s ) && s != "" )
{
ss.clear();
ss.str(s);
ss >> contestant >> problem >> time >> L;
team[contestant].have = 1;
if( L == 'C' && team[contestant].problem[problem][0] != -1 )
{
team[contestant].problem[problem][1] = time + team[contestant].problem[problem][0] * 20;
team[contestant].problem[problem][0] = -1;
}
else if( L == 'I' && team[contestant].problem[problem][0] != -1 )
team[contestant].problem[problem][0]++;
}
for( int j = 0 ; j < 105 ; j++ )
if( team[j].have )
for( int k = 0 ; k < 10 ; k++ )
if( team[j].problem[k][0] == -1 )
{
team[j].AC++;
team[j].time += team[j].problem[k][1];
}
sort( team, team+105, cmp );
for( int j = 0 ; j < 105 ; j++ )
if( team[j].have )
cout << team[j].id << ' ' << team[j].AC << ' ' << team[j].time << endl;
}
}
return 0;
}
view raw UVa10258.cpp hosted with ❤ by GitHub

0 意見:

張貼留言