codeforce 659B

来源:互联网 发布:linux 查看服务器版本 编辑:程序博客网 时间:2024/05/29 07:42
659B 
#include <bits/stdc++.h>using namespace std;#define LL long long#define INF 0x3f3f3f3#define pi acos(-1)const int maxn=1e3+5;const int maxx=1e6+5;set< pair<int,string> >v[11111];string s[111111];int n,m,a[111111],b[111111];int main(){cin>>n>>m;for(int i=1; i<=n; i++){    cin>>s[i]>>a[i]>>b[i];    v[a[i]].insert( make_pair( -b[i],s[i] ) );}   for(int i=1; i<=m; i++){    set< pair<int,string> >::iterator it=v[i].begin();    string q=it->second;    int g=it->first;    v[i].erase(it);    it=v[i].begin();    string w=it->second;    int h=it->first;    v[i].erase(it);    if( v[i].empty() ){        cout<<q<<" "<<w<<endl;        continue;    }    it=v[i].begin();    string tr=it->second;    int jk=it->first;    if( jk==h ){        cout<<"?"<<endl;    }    else{        cout<<q<<" "<<w<<endl;    }   }return 0;}

0 0