1
//
1211 Accepted 46 204 838 C++
2 #include < iostream >
3 #include < cstdlib >
4 #include < string >
5
6 using namespace std ;
7 struct NODE
8 {
9 int solved ;
10 int num ;
11 string name ;
12 };
13 struct NODE data[ 1010 ] ;
14 int inn, inm ;
15
16 int cmp( const void * a, const void * b )
17 {
18 struct NODE * c = ( struct NODE * )a ;
19 struct NODE * d = ( struct NODE * )b ;
20
21 if ( c -> solved != d -> solved )
22 return d -> solved - c -> solved ;
23 else
24 return c -> num - d -> num ;
25 }
26 int main()
27 {
28 while ( cin >> inn )
29 {
30 while ( inn -- )
31 {
32 cin >> inm ;
33 for ( int i = 1 ; i <= inm; i ++ )
34 {
35 cin >> data[i].name ;
36 cin >> data[i].solved ;
37 data[i].num = i ;
38 }
39
40 qsort( data + 1 , inm, sizeof (data[ 1 ]), cmp ) ;
41
42 for ( int i = 1 ; i <= inm; i ++ )
43 {
44 printf( " %d " , i ) ;
45 cout << data[i].name ;
46 printf( " %d\n " , data[i].solved ) ;
47 }
48 }
49 }
50 return 0 ;
51 }
2 #include < iostream >
3 #include < cstdlib >
4 #include < string >
5
6 using namespace std ;
7 struct NODE
8 {
9 int solved ;
10 int num ;
11 string name ;
12 };
13 struct NODE data[ 1010 ] ;
14 int inn, inm ;
15
16 int cmp( const void * a, const void * b )
17 {
18 struct NODE * c = ( struct NODE * )a ;
19 struct NODE * d = ( struct NODE * )b ;
20
21 if ( c -> solved != d -> solved )
22 return d -> solved - c -> solved ;
23 else
24 return c -> num - d -> num ;
25 }
26 int main()
27 {
28 while ( cin >> inn )
29 {
30 while ( inn -- )
31 {
32 cin >> inm ;
33 for ( int i = 1 ; i <= inm; i ++ )
34 {
35 cin >> data[i].name ;
36 cin >> data[i].solved ;
37 data[i].num = i ;
38 }
39
40 qsort( data + 1 , inm, sizeof (data[ 1 ]), cmp ) ;
41
42 for ( int i = 1 ; i <= inm; i ++ )
43 {
44 printf( " %d " , i ) ;
45 cout << data[i].name ;
46 printf( " %d\n " , data[i].solved ) ;
47 }
48 }
49 }
50 return 0 ;
51 }