Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
116879 | 陈家宝 | 给朋友排序 | C++ | 通过 | 100 | 997 MS | 13568 KB | 423 | 2023-12-20 13:36:43 |
#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; }