题意 写个rank
连接点击打开链接
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 105
struct list
{
int num[20], time;
bool flag[20];
int count;
bool submit;
int x;
}s[MAX];
void initialize ( )
{
for ( int i = 0; i < MAX; i++ )
{
for ( int j = 0; j < 20; j++ )
{
s[i].num[j] = 0;
s[i].flag[j] = false;
}
s[i].time = 0;
s[i].x = i;
s[i].count = 0;
s[i].submit = false;
}
}
int cmp ( const void *a, const void *b )
{
list *q, *p;
q = ( list * )a;
p = ( list * )b;
if ( q->count > p->count )
return -1;
if ( q->count < p->count )
return 1;
if ( q->time > q->time )
return 1;
else
return -1;
}
void solve ( )
{
initialize ( );
char str[1000];
while ( gets ( str ) )
{
if ( strlen ( str ) < 2 )
break;
int troop, title, time;
char state;
sscanf ( str, "%d%d%d %c", &troop, &title, &time, &state );
s[troop].submit = true;
if ( state == 'C' && !s[troop].flag[title] )
{
s[troop].count++;
s[troop].flag[title] = true;
s[troop].time += time + s[troop].num[title];
}
if ( state == 'I' )
s[troop].num[title] += 20;
}
qsort ( s, MAX, sizeof s[0], cmp );
for ( int i = 0; i < MAX; i++ )
if ( s[i].submit )
printf ( "%d %d %d\n", s[i].x, s[i]. count, s[i].time );
}
int main ( )
{
int t;
scanf ( "%d\n\n", &t );
while ( t-- )
{
solve ( );
if ( t )
puts ( "" );
}
return 0;
}