Advertisement
codecstasy

UVa 10258

Nov 4th, 2021
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. /*
  2.              codEcsTAsy
  3.             SUST  SWE-19
  4. */
  5. #include <bits/stdc++.h>
  6. #define ll long long
  7. #define s second
  8. #define f first
  9. #define fora(i,n) for(int i=0 ; i<n ; i++)
  10. #define ford(i,n) for(int i=n-1 ; i>=0 ; i--)
  11. #define pb push_back
  12. using namespace std;
  13.  
  14. typedef struct {
  15.     int penalty=0,sol_num=0,sl;
  16.     bool prb[101],entered=false;
  17. }contestant;
  18.  
  19. bool comp(contestant a,contestant b) {
  20.     if(a.sol_num==b.sol_num) {
  21.         if(a.penalty==b.penalty) {
  22.             return a.sl<b.sl;
  23.         }
  24.         return a.penalty<b.penalty;
  25.     }
  26.     return a.sol_num>b.sol_num;
  27. }
  28.  
  29. int main()
  30. {
  31.     ll t;
  32.     t = 1;
  33.     std::cin >> t;
  34.     while( t-- ) {
  35.         contestant cntst[101];
  36.         for(int i=0 ; i<=100 ; i++) {
  37.             cntst[i].sl=i;
  38.             for(int j=1 ; j<=10 ; j++) {
  39.                 cntst[i].prb[j]=false;
  40.             }
  41.         }
  42.         int a,b,c;
  43.         char d;
  44.         //int jhinku=5;
  45.         while(1) {
  46.             cin >> a >> b >> c; //contestant - problem - time - status
  47.             cin >> d;
  48.             //cout << a << b << c << d;
  49.             //cntst[a].sl=a;
  50.             cntst[a].entered=true;
  51.             if(d=='I' && cntst[a].prb[b]!=true) {
  52.                 cntst[a].penalty+=20;
  53.             }
  54.             else if(d=='C' && cntst[a].prb[b]!=true) {
  55.                 cntst[a].penalty+=c;
  56.                 cntst[a].sol_num++;
  57.                 cntst[a].prb[b]=true;
  58.             }
  59.         }
  60.         //vector <contestant> :: iterator it;
  61.         //for(it=cntst.begin() ; it!=cntst.begin() ; it++) //cout << cntst[it].sl << " " << cntst[it].sol_num << " " << cntst[it].penalty << endl;cout << (*it)->sl << " " << (*it)->sol_num << " " << (*it)->penalty << endl;
  62.         sort(cntst,cntst+101,comp);
  63.         for(int i=0 ; i<=100 ; i++) {
  64.             if(cntst[i].entered) {
  65.                 cout << cntst[i].sl << " " << cntst[i].sol_num << " " << cntst[i].penalty << endl;
  66.             }
  67.         }
  68.         cout << endl;
  69.     }
  70.     return 0;
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement