题目传送门
解题思路:
模拟,考完初赛刷道水题,后天公示晋级名单,希望我能进入复赛,rp++.
AC代码:
1 #include<iostream> 2 #include<cstdio> 3 #include<map> 4 #include<algorithm> 5 6 using namespace std; 7 8 int m,tot; 9 map<string,int> p; 10 string l; 11 12 struct kkk{ 13 long long b; 14 string a; 15 }e[200001]; 16 17 long long num(string o) { 18 int len = o.length(); 19 long long u = 0; 20 for(int i = 0;i < len; i++) 21 u = u * 10 + (o[i] - '0'); 22 return u; 23 } 24 25 bool cmp(kkk aa,kkk bb) { 26 return aa.b < bb.b; 27 } 28 29 int main() { 30 scanf("%d",&m); 31 for(int i = 1;i <= m; i++) { 32 cin >> l; 33 if(p.count(l)) 34 p[l]++; 35 else { 36 p[l] = 1; 37 e[++tot].a = l; 38 e[tot].b = num(l); 39 } 40 } 41 sort(e+1,e+1+tot,cmp); 42 for(int i = 1;i <= tot; i++) 43 cout << e[i].a << " " << p[e[i].a] << endl; 44 45 return 0; 46 }