Advertisement
dimon-torchila

Untitled

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