-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnya_and_1100.cpp
More file actions
55 lines (46 loc) · 1.22 KB
/
Anya_and_1100.cpp
File metadata and controls
55 lines (46 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct FastIO {
FastIO() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
} fast_io_setup;
bool hasPattern(const string &s, ll idx) {
return idx >= 0 && idx + 3 < s.size() && s[idx] == '1' && s[idx + 1] == '1' && s[idx + 2] == '0' && s[idx + 3] == '0';
}
int main() {
ll t;
cin >> t;
while(t--) {
string s;
cin >> s;
ll q;
cin >> q;
set<ll> pattern_indices;
for (ll i = 0; i <= (ll)s.length() - 4; i++) {
if (hasPattern(s, i)) {
pattern_indices.insert(i);
}
}
while(q--) {
ll i, v;
cin >> i >> v;
i--;
for (ll j = i - 3; j <= i; j++) {
if (hasPattern(s, j)) {
pattern_indices.erase(j);
}
}
s[i] = v + '0';
for (ll j = i - 3; j <= i; j++) {
if (hasPattern(s, j)) {
pattern_indices.insert(j);
}
}
cout << (pattern_indices.empty() ? "NO\n" : "YES\n");
}
}
}