Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
101966 | Tom0 | 给朋友排序 | C++ | 通过 | 100 | 420 MS | 13568 KB | 634 | 2023-09-11 22:16:51 |
#include <iostream> #include <algorithm> #include <map> using namespace std; typedef long long LL; struct node { string x, m; int id, c; } p[50010]; int n; map<string, int> f; bool cmp(node a, node b) { if (a.c != b.c) return a.c > b.c; return a.id < b.id; } int main() { for (n = 1; cin >> p[n].x >> p[n].m; n++) { f[p[n].x]++; p[n].id = n; } n--; for (int i = 1; i <= n; i++) p[i].c = f[p[i].x]; sort(p + 1, p + n + 1, cmp); for (int i = 1; i <= n; i++) cout << p[i].x << " " << p[i].m << endl; return 0; }