# include <bits/stdc++.h>
# include <set>
# include <map>
# include <queue>
using namespace std;
map<string,int>a;
map<string,int>d;
int book[1001][1001];
typedef struct stu
{
queue<string>q;
}A;
A p[1001];
typedef struct stu1
{
double l;
string s;
}A1;
A1 l1[2000];
bool cmp(A1 x,A1 y)
{
if(x.l==y.l)
{
return x.s<y.s;
}
else
{
return x.l>y.l;
}
}
int main()
{
int n;
int j=1;
int y=1;
cin>>n;
while(n--)
{
string s,s1;
cin>>s>>s1;
if(a[s]==0)
{
a[s]=j;
j++;
}
if(d[s1]==0)
{
d[s1]=y;
y++;
}
if(book[a[s]][d[s1]]==0)
{
p[a[s]].q.push(s1);
book[a[s]][d[s1]]=1;
}
}
for(int i=1;i<j;i++)
{
int z=p[i].q.size();
while(!p[i].q.empty())
{
string h=p[i].q.front();
l1[d[h]].l+=1.0*1/z;
l1[d[h]].s=h;
p[i].q.pop();
}
}
sort(l1+1,l1+y,cmp);
for(int i=1;i<y-1;i++)
{
cout<<l1[i].s<<endl;
}
cout<<l1[y-1].s;
}
利用STL库进行模拟,当时想用map排序,写着写着不会了,哎还是我太菜了。