Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
102421 | 梁乃元 | 给朋友排序 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 666 | 2023-09-13 13:41:57 |
# include <iostream> # include <algorithm> #include <map> using namespace std ; struct name { string xing , ming ; int n ; } ; name a [1145] ; map <string , int> f ; bool cmp ( name x , name y ) { if ( f [x . xing] != f [y . xing] ) { return ( f [x . xing] > f [y . xing] ) ; } return x . n < y . n ; } int main ( ) { string x , m ; int cnt = 0 ; while ( cin >> x >> m ) { cnt ++ ; a [cnt] . xing = x ; a [cnt] . ming = m ; a [cnt] . n = cnt ; f [x] ++ ; } sort ( a + 1 , a + n + 1 , cmp ) ; for ( int i = 1 ; i <= cnt ; i ++ ) { cout << a [i] . xing << ' ' << a [i] . ming << endl ; } return 0 ; }