B. Qualifying Contest
Description
Input
Output
Sample Input
Sample Output
题意:
题解:
代码:
#include<bits/stdc++.h>
using namespace std;
struct node
{
char name[15];
int dui;
int fen;
};
bool cmp(node s1,node s2)
{
return s1.fen > s2.fen;
}
vector <node> s[100100];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
node temp;
for (int i = 1; i <= n; i++)
{
scanf("%s %d %d",temp.name,&temp.dui,&temp.fen);
s[temp.dui].push_back(temp);
}
for (int i = 1; i <= m; i++)
{
sort(s[i].begin(),s[i].end(),cmp);
if (s[i].size()==2)
printf("%s %s\n",s[i][0].name,s[i][1].name);
else {
if (s[i][1].fen == s[i][2].fen)
printf("?\n");
else
printf("%s %s\n",s[i][0].name,s[i][1].name);
}
}
}