Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
143542 | 陈家宝 | 给朋友排序 | C++ | 运行超时 | 87 | 1207 MS | 13564 KB | 423 | 2024-04-16 16:35:07 |
#include<bits/stdc++.h> using namespace std; int n=1; struct node{ string x,y; int pos; }a[50001]; map<string,int> mp; bool cmp(node x,node y){ if(mp[x.x]==mp[y.x]) return x.pos<y.pos; return mp[x.x]>mp[y.x]; } signed main(){ while(cin>>a[n].x>>a[n].y){ mp[a[n].x]++; a[n].pos=n; n++; } n--; sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++) cout<<a[i].x<<" "<<a[i].y<<endl; return 0; }