fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <map>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. struct Country{
  8. string name;
  9. int score;
  10. vector<int> positions;
  11. };
  12. bool operator <(Country A, Country B){
  13. return A.score > B.score;
  14. }
  15.  
  16. int main() {
  17. int i,pos;
  18. string name;
  19. map<string, int> index;
  20. vector<Country> countries;
  21. for(i=1;i<=100;i++){
  22. cin>>pos>>name;
  23. int idx;
  24. if(index[name] == 0){
  25. Country temp;
  26. temp.score = 0;
  27. countries.push_back(temp);
  28. idx = countries.size();
  29. index[name] = idx;
  30. }
  31. else
  32. idx = index[name];
  33.  
  34. countries[idx-1].name = name;
  35. countries[idx-1].score += 101-pos;
  36. countries[idx-1].positions.push_back(pos);
  37. }
  38. sort(countries.begin(),countries.end());
  39. for(i=0;i<countries.size();i++){
  40. cout<<"=SPLIT(\"";
  41. cout<<i+1<<","<<countries[i].name;
  42. // for(int j=countries[i].name.length();j<15;j++)
  43. // cout<<" ";
  44. cout<<",";
  45. cout<<countries[i].score<<",";
  46. for(int j=0;j<countries[i].positions.size();j++){
  47. cout<<countries[i].positions[j];
  48. if(j+1<countries[i].positions.size())
  49. cout<<" ";
  50. }
  51. cout<<"\", \",\")";
  52. cout<<endl;
  53. }
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 3480KB
stdin
1 Serbia
2 Greece
3 Philippines
4 Argentina
5 Croatia
6 Hungary
7 Bulgaria
8 Iran
9 Greece
10 Romania
11 Serbia
12 Romania
13 Bulgaria
14 MKD
15 USA
16 MKD
17 Portugal
18 Chile
19 Romania
20 Slovenia
21 Russia
22 Hungary
23 Turkey
24 Poland
25 Germany
26 Spain
27 Slovenia
28 Russia
29 India
30 Croatia
31 Chile
32 Peru
33 Georgia
34 Venezuela
35 USA
36 Hungary
37 Serbia
38 MKD
39 Finland
40 Greece
41 Finland
42 Slovenia
43 Romania
44 Latvia
45 Spain
46 Romania
47 Poland
48 Croatia
49 Latvia
50 Argentina
51 Hungary
52 Greece
53 Peru
54 USA
55 Hungary
56 Bulgaria
57 Serbia
58 Croatia
59 Serbia
60 Serbia
61 Argentina
62 Hungary
63 Italy
64 Poland
65 Indonesia
66 Romania
67 Poland
68 Poland
69 Bulgaria
70 Japan
71 Hungary
72 Finland
73 Poland
74 Romania
75 USA
76 Turkey
77 Lithuania
78 Serbia
79 UK
80 Argentina
81 Spain
82 USA
83 Netherlands
84 NewZealand
85 Germany
86 Turkey
87 Hungary
88 Hungary
89 Serbia
90 Romania
91 Croatia
92 Italy
93 Romania
94 Romania
95 Ukraine
96 Bulgaria
97 Greece
98 Poland
99 Sweden
100 Taiwan
stdout
=SPLIT("1,Romania,463,10 12 19 43 46 66 74 90 93 94", ",")
=SPLIT("2,Hungary,431,6 22 36 51 55 62 71 87 88", ",")
=SPLIT("3,Serbia,416,1 11 37 57 59 60 78 89", ",")
=SPLIT("4,Greece,305,2 9 40 52 97", ",")
=SPLIT("5,Croatia,273,5 30 48 58 91", ",")
=SPLIT("6,Poland,266,24 47 64 67 68 73 98", ",")
=SPLIT("7,Bulgaria,264,7 13 56 69 96", ",")
=SPLIT("8,USA,244,15 35 54 75 82", ",")
=SPLIT("9,MKD,235,14 16 38", ",")
=SPLIT("10,Slovenia,214,20 27 42", ",")
=SPLIT("11,Argentina,209,4 50 61 80", ",")
=SPLIT("12,Chile,153,18 31", ",")
=SPLIT("13,Russia,153,21 28", ",")
=SPLIT("14,Spain,151,26 45 81", ",")
=SPLIT("15,Finland,151,39 41 72", ",")
=SPLIT("16,Turkey,118,23 76 86", ",")
=SPLIT("17,Peru,117,32 53", ",")
=SPLIT("18,Latvia,109,44 49", ",")
=SPLIT("19,Philippines,98,3", ",")
=SPLIT("20,Iran,93,8", ",")
=SPLIT("21,Germany,92,25 85", ",")
=SPLIT("22,Portugal,84,17", ",")
=SPLIT("23,India,72,29", ",")
=SPLIT("24,Georgia,68,33", ",")
=SPLIT("25,Venezuela,67,34", ",")
=SPLIT("26,Italy,47,63 92", ",")
=SPLIT("27,Indonesia,36,65", ",")
=SPLIT("28,Japan,31,70", ",")
=SPLIT("29,Lithuania,24,77", ",")
=SPLIT("30,UK,22,79", ",")
=SPLIT("31,Netherlands,18,83", ",")
=SPLIT("32,NewZealand,17,84", ",")
=SPLIT("33,Ukraine,6,95", ",")
=SPLIT("34,Sweden,2,99", ",")
=SPLIT("35,Taiwan,1,100", ",")