Is it a very simple problem for you? Please accept it in ten minutes.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
10 Iverson 17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28 Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0
Case #1 Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8 Kidd 9 Jordan 10
//对杭电有的题目真心无语
都是一些莫名其妙的格式
FUCK
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
struct Node
{
char name[100];
int h;
int m;
int no;
} node[10000];
int cmp(Node x,Node y)
{
if(x.h != y.h)
return x.h < y.h;
else if(x.m != y.m)
return x.m < y.m;
else
return strcmp(x.name,y.name)<0;
}
int main()
{
int n;
int cas = 1,fuck = 0;
while(~scanf("%d%*c",&n),n)
{
int i;
for(i = 0; i<n; i++)
{
scanf("%s%d:%d",node[i].name,&node[i].h,&node[i].m);
}
if(fuck!=0)
printf("\n");
sort(node,node+n,cmp);
printf("Case #%d\n",cas++);
int flag = 1;
node[0].no = 1;
for(i = 1;i<n;i++)
{
if(node[i].h == node[i-1].h && node[i].m == node[i-1].m)
node[i].no = flag;
else
node[i].no = flag =i+1;
}
for(i = 0;i<n;i++)
{
printf("%s %d\n",node[i].name,node[i].no);
}
fuck++;
}
return 0;
}
621




被折叠的 条评论
为什么被折叠?



