Advertisement
El_GEMMY

graduation project

Apr 20th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. // Those who cannot remember the past are
  2. // condemned to repeat it (use DP -_-)
  3. // - George Santayana
  4.  
  5. #include <bits/stdc++.h>
  6. #include <ext/pb_ds/assoc_container.hpp>
  7. #include <ext/pb_ds/tree_policy.hpp>
  8.  
  9. using namespace std;
  10. using namespace __gnu_pbds;
  11.  
  12. #define all(v) v.begin(),v.end()
  13. #define rall(v) v.rbegin(),v.rend()
  14. #define ll long long
  15. #define ull unsigned long long
  16. #define MOD 1000000007
  17. #define PI 3.14159265
  18. #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
  19. #define imin INT_MIN
  20. #define imax INT_MAX
  21. #define llmax LLONG_MAX
  22. #define llmin LLONG_MIN
  23. #define inf 2000000000
  24. #define nl '\n'
  25. #define ppcnt __builtin_popcount
  26. #define ppcntll __builtin_popcountll
  27. #define clz __builtin_clz
  28. #define clzll __builtin_clzll
  29. #define ctz __builtin_ctz
  30. #define ctzll __builtin_ctzll
  31. #define modulo(a, b, mod) ((((a) % mod) + ((b) % mod)) % mod)
  32. #define cnte(v, x) count(all(v), (x))
  33. #define mine(v) min_element(all(v))
  34. #define maxe(v) max_element(all(v))
  35. #define debug(x) cout << "x: " << x << nl;
  36. #define debug2(x, y) cout << "x: " << x << " y: " << y << nl;
  37. #define ordered_set tree<pair<int, int>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>
  38. #define ordered_map tree<int, int, less<>, rb_tree_tag, tree_order_statistics_node_update>
  39.  
  40. //vector<int> dx = {0, 0, 1, -1, 1, 1, -1, -1}, dy = {1, -1, 0, 0, 1, -1, 1, -1};
  41. //vector<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};
  42.  
  43. template<typename T = int> istream& operator>>(istream& in, vector<pair<int, int>>& v){
  44.     for (auto& [x, y] : v) in >> x >> y;
  45.     return in;
  46. }
  47.  
  48. template<typename T = int> istream& operator>>(istream& in, vector<T>& v){
  49.     for (T& i : v) in >> i;
  50.     return in;
  51. }
  52.  
  53. template<typename T = int> ostream& operator<<(ostream& out, const vector<T>& v){
  54.     for (const T& x : v)
  55.         out << x << ' ';
  56.     return out;
  57. }
  58.  
  59. template<typename T = pair<ll, ll>> ostream& operator << (ostream& out, const vector<pair<ll, ll>>& v){
  60.     for(auto& [x, y] : v){
  61.         out << x << ' ' << y << nl;
  62.     }
  63.     return out;
  64. }
  65.  
  66. void Start_Crushing() {
  67.     ios_base::sync_with_stdio(false);
  68.     cin.tie(nullptr);
  69.     cout.tie(nullptr);
  70. #ifndef ONLINE_JUDGE
  71.     freopen("input.txt", "r", stdin);
  72.     freopen("output.txt", "w", stdout);
  73. #endif
  74. }
  75. vector<int> freq;
  76. int z;
  77.  
  78. void add_member(vector<bool>& v){
  79.     for(int i = 0; i < v.size(); i++){
  80.         freq[i] += v[i];
  81.         if(freq[i] == 1 and v[i]){
  82.             z--;
  83.         }
  84.     }
  85. }
  86.  
  87. void remove_member(vector<bool>& v){
  88.     for(int i = 0; i < v.size(); i++){
  89.         freq[i] -= v[i];
  90.         if(not freq[i] and v[i]){
  91.             z++;
  92.         }
  93.     }
  94. }
  95.  
  96. void solve(){
  97.     int n, k, x; cin >> n >> k >> x;
  98.     vector<vector<bool>> v;
  99.     freq.resize(k);
  100.  
  101.     vector<bool> p;
  102.     for(int i = 0; i < n; i++){
  103.         int s; cin >> s;
  104.         p.emplace_back(s);
  105.  
  106.         if(p.size() == k)
  107.             v.emplace_back(p), p.clear();
  108.     }
  109.  
  110.     z = k;
  111.     int l = 0, r = 0;
  112.     while(r - l + 1 != x)
  113.         add_member(v[r++]);
  114.  
  115.     for(; r < v.size(); r++){
  116.         add_member(v[r]);
  117.         if(not z){
  118.             return void(cout << "YES");
  119.         }
  120.         remove_member(v[l++]);
  121.     }
  122.     cout << "NO";
  123. }
  124.  
  125. int main(){
  126.     Start_Crushing();
  127.  
  128.     int t = 1;
  129. //    /*Multiple test cases?*/ cin >> t;
  130.     while (t--) {
  131.         solve();
  132.         if(!t)
  133.             break;
  134.         cout << nl;
  135.     }
  136.  
  137. //    for(int tc = 1; tc <= t; tc++){
  138. //        cout << "Case #" << tc << ": ";
  139. //        solve();
  140. //        if(tc != t)
  141. //            cout << nl;
  142. //    }
  143.  
  144.     return 0;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement