Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int t, n, id, s, tp, m, sum = 1e6 + 10, z = 0;
- struct Rank
- {
- int S, TP, M;
- vector<int>TS;
- };
- vector<Rank>v(100);
- vector< int > ts, tt, in, ini(100);
- vector< pair< int , int > > ans(100);
- bool isTrue(){
- for(int i = 0; i < n-1; i++){
- int x = in[i];
- int y = in[i+1];
- if(ans[x].first < ans[y].first)return false;
- else if(ans[x].first == ans[y].first
- && ans[x].second > ans[y].second)return false;
- }
- return true;
- }
- bool Gen(vector<int>in, int n, int mm, bool t){
- if(t)return true;
- if(mm <= 0)return false;
- for(int i = 0; i < n-1; i++){
- int x = in[i];
- int y = in[i+1];
- int j = v[x].M;
- int k = ans[x].first - v[x].S;
- int t = 0;
- while(ans[x].first <= v[y].S && k < j){
- ans[x].first++;
- ans[x].second += v[x].TS[k++];
- }
- z = x;
- }
- Gen(in, n, mm-1, isTrue());
- }
- int main()
- {
- //freopen("In.txt", "r", stdin);
- //freopen("Out.txt", "w", stdout);
- scanf("%d", &t);
- for(int z = 0; z < t; z++){
- sum = 1e6 + 10;
- v.clear();
- in.clear();
- ans.clear();
- scanf("%d", &n);
- for(int zz = 0; zz < n; zz++){
- ts.clear();
- scanf("%d %d %d %d", &id, &s, &tp, &m);
- for(int i = 0; i < m; i++){
- int x;
- scanf("%d", &x);
- ts.push_back(x);
- }
- v[id] = {s, tp, m, ts};
- }
- int test = 0;
- for(int zz = 0; zz < n; zz++){
- int x;
- scanf("%d", &x);
- in.push_back(x);
- }
- for(int i = 1; i <= n; i++){
- ans[i].first = v[i].S;
- ans[i].second = v[i].TP;
- }
- if(!Gen(in, n, n, false)){
- printf("Case %d: Say no to rumour >:\n", z+1);
- }else {
- printf("Case %d: We respect our judges :)\n", z+1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement