Advertisement
wery00

Untitled

Feb 26th, 2021
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.97 KB | None | 0 0
  1. #pragma GCC optimize("Ofast")
  2. // #pragma GCC target("avx,avx2,fma")
  3.  
  4. #include<bits/stdc++.h>
  5.  
  6. #define F first
  7. #define S second
  8. #define vec vector
  9. #define pb push_back
  10. #define cld complex<ld>
  11. #define pll pair<ll, ll>
  12. #define pdd pair<ld, ld>
  13. #define umap unordered_map
  14. #define uset unordered_set
  15. #define pii pair<int, int>
  16. #define pnn pair<Node*, Node*>
  17. #define all(m) m.begin(), m.end()
  18. #define uid uniform_int_distribution
  19. #define init(m, x) memset(m, x, sizeof(m));
  20. #define pripii(p) cout << "{" << p.F << ", " << p.S << "} "
  21. #define FILE ifstream in("input.txt"); ofstream out("output.txt");
  22. #define fast cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0);
  23. using namespace std;
  24. typedef string str;
  25. typedef long long ll;
  26. typedef long double ld;
  27. typedef unsigned int uint;
  28. typedef unsigned long long ull;
  29. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  30.  
  31. const int G = 110, D = 11e3;
  32. int n, m, k, a, b;
  33. vec<vec<int>> l[D];
  34. int res[D][G], sm[D];
  35. int fsm;
  36.  
  37. int chk(int x, int d){
  38.     if(fsm<d) return 0;
  39. //    for(int q=0; q<d; q++){
  40. //        for(int w=0; w<n; w++){
  41. //            if(res[q][w]==1) return 0;
  42. //        }
  43. //    }
  44.     int fir[n]; init(fir, -1);
  45.     fir[x] = d;
  46.     for(; d<D; d++){
  47.         int sick[n] = {0}, infe[n] = {0};
  48.         for(int q=0; q<n; q++){
  49.             if(fir[q]==-1) continue;
  50.             int df = d-fir[q];
  51.             sick[q] = df<b;
  52.             infe[q] = a<=df && df<b;
  53.         }
  54.         for(int q=0; q<n; q++){
  55.             if(res[d][q]!=-1 && res[d][q]!=sick[q]) return 0;
  56.         }
  57.         for(vec<int> &u : l[d]){
  58.             int fl = 0;
  59.             for(int i : u) fl |= infe[i];
  60.             if(fl){
  61.                 for(int i : u){
  62.                     if(fir[i]==-1) fir[i] = d;
  63.                 }
  64.             }
  65.         }
  66.     }
  67.     return 1;
  68. }
  69.  
  70. ifstream in("C:\\Users\\Bogdan\\ClionProjects\\EZZ\\input.txt");
  71. ofstream out("C:\\Users\\Bogdan\\ClionProjects\\EZZ\\output.txt");
  72. void solve(){
  73.     for(int q=0; q<D; q++){
  74.         l[q].clear();
  75.     }
  76.     in>>n>>m>>k>>a>>b;
  77.     for(int q=0; q<m; q++){
  78.         int d, cnt; in>>d>>cnt;
  79.         vec<int> u(cnt);
  80.         for(int w=0; w<cnt; w++){
  81.             in>>u[w]; u[w]--;
  82.         }
  83.         l[d].pb(u);
  84.     }
  85.     init(res, -1);
  86.     init(sm, 0);
  87.     for(int q=0; q<k; q++){
  88.         int d, y, z; in>>d>>y>>z; y--;
  89.         res[d][y] = z;
  90.         sm[d] += z;
  91.     }
  92.     fsm = 1e9;
  93.     for(int q=0; q<D; q++) {
  94.         if(sm[q]) {
  95.             fsm = q;
  96.             break;
  97.         }
  98.     }
  99.     for(int q=0; q<n; q++){
  100.         cout<<"GO: "<<q<<endl;
  101.         for(int d=0; d<D; d++){
  102.             int tyt = chk(q, d);
  103.             if(tyt==1){
  104.                 out<<q+1<<" "<<d<<endl;
  105.                 cout<<q+1<<" "<<d<<endl;
  106.                 return;
  107.             }
  108.         }
  109.     }
  110.     out<<"LOX LOX"<<endl;
  111.     cout<<"LOX LOX"<<endl;
  112. }
  113.  
  114. int main() {
  115.     fast;
  116.     ll z; in>>z;
  117.     for(; z--;){
  118.         solve();
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement