Advertisement
azizulhaquealif

Problem C in Preliminary

Oct 14th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int t, n, id, s, tp, m, sum = 1e6 + 10, z = 0;
  6.  
  7. struct Rank
  8. {
  9.     int S, TP, M;
  10.     vector<int>TS;
  11. };
  12.  
  13. vector<Rank>v(100);
  14. vector< int > ts, tt, in, ini(100);
  15. vector< pair< int , int > > ans(100);
  16.  
  17. bool isTrue(){
  18.     for(int i = 0; i < n-1; i++){
  19.         int x = in[i];
  20.         int y = in[i+1];
  21.  
  22.         if(ans[x].first < ans[y].first)return false;
  23.         else if(ans[x].first == ans[y].first
  24.            && ans[x].second > ans[y].second)return false;
  25.     }
  26.     return true;
  27. }
  28.  
  29. bool Gen(vector<int>in, int n, int mm, bool t){
  30.  
  31.     if(t)return true;
  32.     if(mm <= 0)return false;
  33.  
  34.     for(int i = 0; i < n-1; i++){
  35.         int x = in[i];
  36.         int y = in[i+1];
  37.         int j = v[x].M;
  38.  
  39.         int k = ans[x].first - v[x].S;
  40.         int t = 0;
  41.  
  42.         while(ans[x].first <= v[y].S && k < j){
  43.             ans[x].first++;
  44.             ans[x].second += v[x].TS[k++];
  45.         }
  46.         z = x;
  47.     }
  48.     Gen(in, n, mm-1, isTrue());
  49. }
  50.  
  51. int main()
  52. {
  53.     //freopen("In.txt", "r", stdin);
  54.     //freopen("Out.txt", "w", stdout);
  55.  
  56.     scanf("%d", &t);
  57.     for(int z = 0; z < t; z++){
  58.  
  59.         sum = 1e6 + 10;
  60.         v.clear();
  61.         in.clear();
  62.         ans.clear();
  63.  
  64.         scanf("%d", &n);
  65.  
  66.         for(int zz = 0; zz < n; zz++){
  67.  
  68.             ts.clear();
  69.             scanf("%d %d %d %d", &id, &s, &tp, &m);
  70.  
  71.             for(int i = 0; i < m; i++){
  72.                 int x;
  73.                 scanf("%d", &x);
  74.                 ts.push_back(x);
  75.             }
  76.             v[id] = {s, tp, m, ts};
  77.         }
  78.  
  79.         int test = 0;
  80.  
  81.         for(int zz = 0; zz < n; zz++){
  82.             int x;
  83.             scanf("%d", &x);
  84.             in.push_back(x);
  85.         }
  86.  
  87.         for(int i = 1; i <= n; i++){
  88.             ans[i].first = v[i].S;
  89.             ans[i].second = v[i].TP;
  90.         }
  91.  
  92.         if(!Gen(in, n, n, false)){
  93.             printf("Case %d: Say no to rumour >:\n", z+1);
  94.         }else {
  95.             printf("Case %d: We respect our judges :)\n", z+1);
  96.         }
  97.  
  98.     }
  99.  
  100.     return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement