标签:rank end tin tip val struct time ted miss
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7987 Accepted Submission(s): 2735
1 #include<cstdio>
2 #include<iostream>
3 #include<string>
4 #include<algorithm>
5 #include<cstring>
6 #include<string>
7 using namespace std;
8 struct node
9 {
10 string name;
11 int a,b;
12 char c;
13 int flag;
14 }g[15];
15 bool cmp(struct node x,struct node y)
16 {
17 if(x.a==y.a&&x.b==y.b)
18 {
19 return x.name<y.name;
20 }
21 if(x.a==y.a)
22 return x.b<y.b;
23 return x.a<y.a;
24 }
25 int main()
26 {
27 long long n,t,i;
28 int ans=1;
29 while(cin>>n&&n)
30 {
31 for(i=1;i<=n;i++)
32 {
33 getchar();
34 cin>>g[i].name;
35 cin>>g[i].a;
36 cin>>g[i].c;
37 cin>>g[i].b;
38 g[i].flag=0;
39 }
40 if(ans!=1)
41 cout<<endl;
42 cout<<"Case #"<<ans++<<endl;
43 sort(g+1,g+n+1,cmp);
44 sort(g+1,g+n+1,cmp);
45 for(i=1;i<=n;i++)
46 {
47 if(g[i].a==g[i-1].a&&g[i].b==g[i-1].b)
48 {
49 for(int k=i;k>=0;k--)
50 {
51 if(g[i].a!=g[k].a||(g[i].a==g[k].a&&g[i].b!=g[k].b))
52 {
53 cout<<g[i].name<<‘ ‘<<k+1<<endl;
54 break;
55 }
56 }
57 }
58 else
59 cout<<g[i].name<<‘ ‘<<i<<endl;
60 }
61 }
62 }
标签:rank end tin tip val struct time ted miss
原文地址:http://www.cnblogs.com/--lr/p/7017032.html