Advertisement
dimon-torchila

Untitled

Sep 7th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<vector>
  4. #include<sstream>
  5. #include<set>
  6. #include<queue>
  7. #include<algorithm>
  8. #include <type_traits>
  9. using namespace std;
  10.  
  11. struct Player {
  12.  
  13. Player(int score, int penalty, string id) : score(score), penalty(penalty), id(id) {}
  14. int score;
  15. int penalty;
  16. string id;
  17. };
  18.  
  19. bool comp(const Player& p1, const Player& p2) {
  20. return p1.score > p2.score || (p1.score == p2.score && p1.penalty < p2.penalty);
  21. }
  22. using Comp = std::integral_constant<decltype(&comp), &comp>;
  23.  
  24. struct Competition {
  25. Competition(int count) : player_places(count) {}
  26. int player_places;
  27. set <Player, Comp> players(Comp);
  28. };
  29.  
  30.  
  31. int main()
  32. {
  33. int n;
  34. cin >> n;
  35. map<string, Competition> m;
  36. for (int i = 0; i < n; ++i)
  37. {
  38. string s;
  39. cin >> s;
  40. int tmp = s.find(',');
  41. m.insert({ s.substr(0, tmp),
  42. *(new Competition(stoi(s.substr(tmp + 1, s.size())))) });
  43.  
  44. }
  45. int k;
  46. cin >> k;
  47. for (int i = 0; i < k; ++i) {
  48. string s;
  49. cin >> s;
  50. int tmp = s.find(',');
  51. string id = s.substr(0, tmp);
  52. int tmp2 = s.find(',', tmp + 1) - tmp - 1;
  53. string comp = s.substr(tmp + 1, tmp2);
  54. tmp += tmp2 + 1;
  55. tmp2 = s.find(',', tmp + 1) - tmp - 1;
  56. int score = stoi(s.substr(tmp + 1, tmp2));
  57. tmp += tmp2 + 1;
  58. int penalty = stoi(s.substr(tmp + 1, s.size()));
  59. m[comp].players.insert(*(new Player(score, penalty, id)));
  60. }
  61.  
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement