Saleh127

UVA 10258 / Implementation

Oct 5th, 2021 (edited)
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. bool team[200];
  6. bool solved[200][20];
  7. ll pnlt[200][20];
  8.  
  9. bool cmp(pair<ll,pair<ll,ll>>a, pair<ll,pair<ll,ll>>b)
  10. {
  11.     if(a.second.first!=b.second.first)
  12.     {
  13.         return a.second.first>b.second.first;
  14.     }
  15.  
  16.     if(a.second.second!=b.second.second)
  17.     {
  18.         return a.second.second<b.second.second;
  19.     }
  20.     else
  21.     {
  22.         return a.first<b.first;
  23.     }
  24. }
  25.  
  26. int main()
  27. {
  28.  
  29.     int cs;
  30.    
  31.     cin>>cs;
  32.  
  33.     getchar();
  34.     getchar();
  35.  
  36.     while(cs--)
  37.     {
  38.         memset(team,0,sizeof team);
  39.         memset(pnlt,0,sizeof pnlt);
  40.         memset(solved,0,sizeof solved);
  41.  
  42.         string a;
  43.  
  44.         while(getline(cin,a) && a.size())
  45.         {
  46.             stringstream ss(a);
  47.             ll tm,pr,time;
  48.             string ac;
  49.  
  50.             ss>>tm>>pr>>time>>ac;
  51.  
  52.             team[tm]=1;
  53.  
  54.             if(ac[0]=='C' && solved[tm][pr]==0)
  55.             {
  56.                 solved[tm][pr]=1;
  57.                 pnlt[tm][pr]+=time;
  58.             }
  59.             else if(ac[0]=='I' && solved[tm][pr]==0)
  60.             {
  61.                 pnlt[tm][pr]+=20;
  62.             }
  63.         }
  64.  
  65.         vector<pair<ll,pair<ll,ll>>>x;
  66.  
  67.         for(ll i=1; i<=100; i++)
  68.         {
  69.             if(team[i]==0) continue;
  70.  
  71.             ll pr=0,p=0;
  72.  
  73.             for(ll j=1; j<=9; j++)
  74.             {
  75.                 if(solved[i][j]!=0)
  76.                 {
  77.                     pr++;
  78.                     p+=pnlt[i][j];
  79.                 }
  80.             }
  81.  
  82.             x.push_back({i,{pr,p}});
  83.         }
  84.  
  85.         sort(x.begin(),x.end(),cmp);
  86.  
  87.         for(auto dd:x)
  88.         {
  89.             cout<<dd.first<<" "<<dd.second.first<<" "<<dd.second.second<<endl;
  90.         }
  91.  
  92.         if(cs) cout<<endl;
  93.     }
  94.  
  95.     return 0;
  96. }
  97.  
Add Comment
Please, Sign In to add comment