Topic links
Idea: STL Dafa Good to remove the end of the character 0, and then compare the size of the string, while using the automatic map of the name in accordance with the dictionary output, >>>stl Dafa good
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<map>#include<Set>#include<vector>using namespacestd;Const intn=2e5+Ten; Map<string,int>A;map<string,string>b;structnode{stringb;} C[i]; voidSolvestring&S1) { intlen1=s1.size (); Auto It=s1.end (); it--; while(It!=s1.begin () &&*it=='0') S1.erase (IT), it--;} typedef pair<string,string>P;vector<P>VV;BOOLCMP (P s1,p s2) {returns1.second>s2.second| | (s1.second==s2.second&&s1.first<s2.first);}intMain () {Std::ios::sync_with_stdio (false); Cin.tie (0); intN; while(cin>>N) { strings1,s2; while(!vv.empty ()) Vv.pop_back (); A.clear (), b.clear (); for(intI=1; i<=n;i++) {cin>>s1>>S2; D[I].A=s1,d[i].b=S2; Solve (s2); Vv.push_back ({s1,s2}), A[s1]=i; } inttot=1; Sort (Vv.begin (), Vv.end (), CMP); for(Auto It=vv.begin (); It!=vv.end (); it++){ stringTmp=it->First ; cout<<tmp<<" "<<d[a[tmp]].b<<Endl; } } return 0;}
View Code
Mr. WO students ' grades +STL delete operation of string, add map auto-sort