Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
143546 陈家宝 给朋友排序 C++ 通过 100 517 MS 13568 KB 550 2024-04-16 16:39:01

Tests(8/8):


#include<bits/stdc++.h> 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; }


测评信息: