Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
101855 梁晨熙 给朋友排序 C++ 解答错误 0 1060 MS 13568 KB 425 2023-09-11 13:37:35

Tests(0/8):


#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-=2; sort(a+1,a+n+1,cmp); for(int i=1;i<n;i++){ cout<<a[i].x<<" "<<a[i].y<<endl; } return 0; }


测评信息: