Advertisement
erfanul007

UVa 10258

Sep 15th, 2021
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.26 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. #ifdef ERFANUL007
  6.     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
  7.     template < typename Arg1 >
  8.     void __f(const char* name, Arg1&& arg1){
  9.         cout << name << " = " << arg1 << std::endl;
  10.     }
  11.     template < typename Arg1, typename... Args>
  12.     void __f(const char* names, Arg1&& arg1, Args&&... args){
  13.         const char* comma = strchr(names, ',');
  14.         cout.write(names, comma - names) << " = " << arg1 <<" | ";
  15.         __f(comma+1, args...);
  16.     }
  17. #else
  18.     #define debug(...)
  19. #endif
  20.  
  21. bool participated[101];
  22. bool solved[101][10];
  23. int penalty[101][10];
  24.  
  25. bool cmp(pair< pair< int, int >, int > a, pair< pair< int, int >, int > b){
  26.     if(a.first.second != b.first.second) return a.first.second > b.first.second;
  27.     if(a.second != b.second) return a.second < b.second;
  28.     return a.first.first < b.first.first;
  29. }
  30.  
  31. int main(){
  32.     #ifdef ERFANUL007
  33.         clock_t tStart = clock();
  34.         freopen("input.txt", "r", stdin);
  35.         freopen("output.txt", "w", stdout);
  36.     #endif
  37.  
  38.     int t, cs=0;
  39.     cin >> t;
  40.     getchar();
  41.     getchar();
  42.  
  43.     while(t--){
  44.         memset(participated, 0, sizeof(participated));
  45.         memset(solved, 0, sizeof(solved));
  46.         memset(penalty, 0, sizeof(penalty));
  47.  
  48.         if(cs++) cout << '\n';
  49.  
  50.         string s;
  51.         while(getline(cin, s) && s.size()){
  52.             //debug(s);
  53.  
  54.             stringstream ss(s);
  55.             int team;
  56.             ss >> team;
  57.             int problem;
  58.             ss >> problem;
  59.             int time;
  60.             ss >> time;
  61.             string status;
  62.             ss >> status;
  63.  
  64.             participated[team] = 1;
  65.  
  66.             if(status[0] == 'C' && !solved[team][problem]){
  67.                 solved[team][problem] = true;
  68.                 penalty[team][problem] += time;
  69.             }
  70.             else if(status[0] == 'I' && !solved[team][problem]){
  71.                 penalty[team][problem] += 20;
  72.             }
  73.         }
  74.         vector< pair< pair< int, int >, int > > scoreboard;
  75.         for(int i=1; i<=100; i++){
  76.             if(!participated[i]) continue;
  77.             int problem = 0, pen = 0;
  78.             for(int j=1; j<=9; j++){
  79.                 if(!solved[i][j]) continue;
  80.                 problem++;
  81.                 pen += penalty[i][j];
  82.             }
  83.             scoreboard.push_back(make_pair(make_pair(i, problem), pen));
  84.         }
  85.         sort(scoreboard.begin(), scoreboard.end(), cmp);
  86.  
  87.         for(auto it : scoreboard){
  88.             cout << it.first.first << ' ' << it.first.second << ' ' << it.second << '\n';
  89.         }
  90.  
  91.     }
  92.  
  93.     #ifdef ERFANUL007
  94.         fprintf(stderr, ">>> Runtime : %.9f\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  95.     #endif
  96.  
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement