Advertisement
CyberN00b

Untitled

Sep 7th, 2022
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 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. 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() {}
  26.     Competition(int count) : player_places(count) {}
  27.     int player_places;
  28.     set <Player, Comp> players(Comp) ;
  29. };
  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. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement