1 条题解
-
1
#include<bits/stdc++.h> using namespace std; struct node { string s; int x; }; vector<node>a; bool cmp(node xx,node yy) { return xx.x<yy.x; } set<pair<string,int> >st; int main() { int n; cin>>n; cin.ignore(numeric_limits<streamsize>::max(),'\n'); int i; for(i=1;i<=n;i++) { string s; getline(cin,s); size_t l=s.find_last_of(' '); if(l==string::npos)continue; string ns=s.substr(0,l); string t=s.substr(l+1); int x=stoi(t); pair<string,int>k={ns,x}; if(st.find(k)==st.end()) { st.insert(k); a.push_back({ns,x}); } } sort(a.begin(),a.end(),cmp); for(i=0;i<a.size();i++) { cout<<a[i].x<<' '<<a[i].s<<endl; } }
信息
- ID
- 2858
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 493
- 已通过
- 136
- 上传者