Advertisement
rafid_shad

ICPC C 19

Sep 30th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.02 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. //*****************Data type**********************//
  5. typedef long long ll;
  6. typedef long long int lli;
  7. typedef unsigned long long  ull;
  8. typedef unsigned long long int ulli;
  9.  
  10. //*****************Map****************************//
  11. typedef map<int, int> mp;
  12. typedef map<int, string> mps;
  13. typedef map<int, char>mpc;
  14. typedef map<string, int>mpsi;
  15. typedef map<char, int>mpci;
  16.  
  17. //****************Pair****************************//
  18. typedef pair<int, int> pii;
  19. typedef pair<string, string> pss;
  20. typedef pair<char, char> pcc;
  21. typedef pair<int, string> pis;
  22. typedef pair<int, char> pic;
  23.  
  24. //*****************Vector************************//
  25. typedef vector<int> VI;
  26. typedef vector<string> VS;
  27. typedef vector<double> VD;
  28. typedef vector<lli> VLLI;
  29. typedef vector<VI> VVI;
  30. typedef vector<pii> VPI;
  31.  
  32. //****************SET**************************//
  33. typedef set<int> SI;
  34. typedef set<string> SS;
  35. typedef set<char>SC;
  36.  
  37. //-------------------------------------------------------------------------------//
  38. #define pp1(A)              printf("%d\n",A)
  39. #define pp2(A,B)            printf("%d %d\n",A,B)
  40. #define pp3(A,B,C)          printf("%d %d %d\n",A,B,C)
  41.  
  42. #define ss1(A)              scanf("%d", &A)
  43. #define ssl(A)              scanf("%lld", &A)
  44. #define ss2(A,B)            scanf("%d,%d",&A,&B)
  45. #define ss3(A,B,C)          scanf("%d,%d,%d",&A,&B,&C)
  46.  
  47. //--------------------------------------------------------------------------------//
  48. #define nosync              ios_base::sync_with_stdio(false), cin.tie(NULL)
  49. #define pf                  push_front
  50. #define pb                  push_back
  51. #define popb                pop_back()
  52. #define popf                pop_front()
  53. #define itr                 iterator
  54. #define mk                  make_pair
  55. #define ff                  first
  56. #define ss                  second
  57. #define END                 return 0
  58. #define line                printf("\n")
  59. #define yes                 printf("YES\n")
  60. #define no                  printf("NO\n")
  61. #define enter               printf("Entered\n")
  62. #define Case(k,n)           printf("Case %d: %d\n",k,n)
  63. #define sq(a)               (a)*(a)
  64. #define SZ(a)               (int)a.size()
  65. #define all(a)              (a).begin(), (a).end()
  66. #define sortV(v)            sort(all(v))
  67. #define sortA(a,n)          sort(a,a+n)
  68.  
  69. #define Erase(V,I)          (V).erase((V).begin()+I)
  70. #define Insert(V,I,M)       (V).insert((V).begin()+I,M)
  71. #define max3(a,b,c)         max(max(a,b),c)
  72. #define max4(a,b,c,d)       max(max3(a,b,c),d)
  73. #define min3(a,b,c)         min(min(a,b),c)
  74. #define min4(a,b,c,d)       min(min3(a,b,c),d)
  75. #define READ()              freopen("input.txt", "r", stdin)
  76. #define WRITE()             freopen("output.txt", "w", stdout)
  77.  
  78. //********************************************************************************//
  79. #define loop(i,n)           for(int i=0;i<n;i++)
  80. #define loops(i,x,n)        for(int i=x;i<n;i++)
  81. #define loopr(i,n)          for(int i=n-1;i>=0;i--)
  82. #define loopt(i,n)          for(int i=1;i<=n;i++)
  83. #define vin(V, N)           for(int i=0; i<N; i++){ int X; ss1(X); V.pb(X); }
  84. #define vinll(V, N)         for(int i=0; i<N; i++){ lli X; ssl(X); V.pb(X); }
  85. #define scanA(A, N)         for(int i=0; i<N; i++){ ss1(A[i]); }
  86. #define scanAll(A, N)       for(int i=0; i<N; i++){ ssl(A[i]); }
  87. #define printA(A, N)        for(int i=0; i<N; i++){ cout<<A[i]; if (i<N-1)cout<<" ";else cout<<endl; }
  88. #define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout <<" "; else cout << endl;}
  89.  
  90. /*-----------------------GCD && LCM------------------*/
  91. int gcd(int a, int b)
  92. {
  93.     return b == 0 ? a : gcd(b, a % b);
  94. }
  95. int lcm(int a, int b)
  96. {
  97.     return a * (b / gcd(a, b));
  98. }
  99.  
  100. /*----------------------Graph Moves----------------*/
  101. int ROW[]= {+1,-1,+0,+0};
  102. int COL[]= {+0,+0,+1,-1};
  103.  
  104. /*----------------------Kings Move-----------------*/
  105. int X[]= {+0,+0,+1,-1,-1,+1,-1,+1};
  106. int Y[]= {-1,+1,+0,+0,+1,+1,-1,-1};
  107.  
  108. /*----------------------Knights Move----------------*/
  109. int KX[]= {-2, -2, -1, -1,  1,  1,  2,  2};
  110. int KY[]= {-1,  1, -2,  2, -2,  2, -1,  1};
  111.  
  112. //---------------------------------*START*-----------------------------------------//
  113. bool flag;
  114.  
  115. int solve=0,penalty=0;
  116.  
  117. struct student
  118. {
  119.     int id,solve,tp,m;
  120.     int solve_after,tp_after;
  121.     int m1[60];
  122. };
  123.  
  124.  
  125. int main()
  126. {
  127.     int k;
  128.     cin>>k;
  129.     int shad=0;
  130. lol:
  131.     while(k--)
  132.     {
  133.         shad++;
  134.         struct student st[50];
  135.         int n;
  136.         cin>>n;
  137.         int c[n];
  138.         loop(i,n)
  139.         {
  140.             cin>>st[i].id;
  141.             cin>>st[i].solve;
  142.             cin>>st[i].tp;
  143.             cin>>st[i].m;
  144.             int x=st[i].m;
  145.             //cout<<x<<endl;
  146.             st[i].solve_after=st[i].solve+x;
  147.             st[i].tp_after=st[i].tp;
  148.             loop(j,x)
  149.             {
  150.                 cin>>st[i].m1[j];
  151.                 st[i].tp_after+=st[i].m1[j];
  152.             }
  153.            
  154.         }
  155.         loop(i,n)
  156.         {
  157.             cin>>c[i];
  158.         }
  159.         int pp,sol;
  160.  
  161.         loop(i,n)
  162.         {
  163.             int count=0;
  164.             loop(j,n)
  165.             {
  166.                 if(c[i]==st[j].id)
  167.                 {
  168.                     if(i==0)
  169.                     {
  170.                         sol=st[j].solve_after;
  171.                         pp=st[j].tp_after;
  172.  
  173.                     }
  174.                     else
  175.                     {
  176.                         if(st[j].solve>sol)
  177.                         {
  178.                             cout<<"Case "<<shad<<": Say no to rumour >:"<<endl;
  179.                             goto lol;
  180.                         }
  181.                        
  182.                         else  if(st[j].solve_after<sol)
  183.                         {
  184.                             sol=st[j].solve_after;
  185.                             pp=st[j].tp_after;
  186.                             //cout<<" We respect our judges :)"<<endl;
  187.  
  188.                         }
  189.                         else if(st[j].solve_after==sol and st[j].tp_after>=pp)
  190.                         {
  191.                             sol=st[j].solve_after;
  192.                             pp=st[j].tp_after;
  193.                             // cout<<"We respect our judges :)"<<endl;
  194.                         }
  195.  
  196.                         else
  197.                         {
  198.                             int yy=st[j].m;
  199.                             int zz=st[j].m;
  200.                             yy--;
  201.                             int cheak=0;
  202.                             //cout<<"Penalty before "<<st[j].tp_after<<endl;
  203.                             while(st[j].solve_after>st[j].solve )
  204.                             {
  205.                                 st[j].solve_after--;
  206.                                 st[j].tp_after-=st[j].m1[yy];
  207.                                 yy--;
  208.                                 if(st[j].solve_after<sol)
  209.                                 {
  210.                                     sol=st[j].solve_after;
  211.                                     pp=st[j].tp_after;
  212.                                     cheak=1;
  213.                                     //no;
  214.                                     break;
  215.                                 }
  216.                                 else if(st[j].solve_after==sol and st[j].tp_after>=pp)
  217.                                 {
  218.                                     sol=st[j].solve_after;
  219.                                     pp=st[j].tp_after;
  220.                                     cheak=1;
  221.                                     //yes;
  222.                                     break;
  223.                                 }
  224.  
  225.                             }
  226.                             if(!cheak)
  227.                             {
  228.                                 cout<<"Case "<<shad<<": Say no to rumour >:"<<endl;
  229.                                 goto lol;
  230.                             }
  231.  
  232.                         }
  233.  
  234.                     }
  235.                 }
  236.  
  237.             }
  238.             //cout<<"Case  solve "<<sol<<" penalty "<<pp<<endl;
  239.         }
  240.         cout<<"Case "<<shad<<": We respect our judges :)"<<endl;
  241.  
  242.     }
  243.     END;
  244.  
  245. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement