Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <algorithm>
- #include <string>
- #include <set>
- #include <map>
- #include <vector>
- #include <stack>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int t; cin >> t;
- while (t--) {
- string s; cin >> s;
- int n=s.length();
- int f=0;
- if (n>3) {
- for (int i=0; i<n-3; i++) {
- if (s.substr(i,4)=="1100") f++;
- }
- }
- int q; cin >> q;
- while (q--) {
- int y, x; cin >> y >> x; y--;
- if (n<4) cout << "NO" << endl;
- else if (n<10) {
- int no=1;
- for (int i=0; i<n-3; i++) {
- s[y]=x+'0';
- if (s.substr(i,4)=="1100") {
- cout << "YES" << endl;
- no=0;
- break;
- }
- }
- if (no) cout << "NO" << endl;
- }
- else {
- if (s.substr(y,4)=="1100" && y<n-3) f--;
- if (s.substr(y-1,4)=="1100" && y>0 && y<n-2) f--;
- if (s.substr(y-2,4)=="1100" && y>1 && y<n-1) f--;
- if (s.substr(y-3,4)=="1100" && y>2) f--;
- s[y]=x+'0';
- if (s.substr(y,4)=="1100" && y<n-3) f++;
- if (s.substr(y-1,4)=="1100" && y>0 && y<n-2) f++;
- if (s.substr(y-2,4)=="1100" && y>1 && y<n-1) f++;
- if (s.substr(y-3,4)=="1100" && y>2) f++;
- if (f) cout << "YES" << endl;
- else cout << "NO" << endl;
- }
- }
- }
- return 0;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment