Ankit_132

A

Jan 10th, 2024
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         int n, x;
  14.         string s;
  15.         cin>>n>>x>>s;
  16.  
  17.         int rem = 0;
  18.         int possible = 1;
  19.  
  20.         for(int i=0; i<n; i++)
  21.         {
  22.             if(s[i] == '0')
  23.             {
  24.                 if(rem == 0)
  25.                 {
  26.                     possible = 0;
  27.                     break;
  28.                 }
  29.  
  30.                 rem--;
  31.             }
  32.             else
  33.                 rem = x;
  34.         }
  35.  
  36.         if(possible)        cout<<"YES\n";
  37.         else                cout<<"NO\n";
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment