-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2036C.cpp
More file actions
89 lines (70 loc) · 2 KB
/
Copy path2036C.cpp
File metadata and controls
89 lines (70 loc) · 2 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define umap unordered_map
#define f(i, x, n) for(ll i = x; i < n; i++)
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
optimize();
ll t;
cin >> t;
while (t--) {
string s;
cin >> s;
ll n = s.size();
map <string, ll> mp;
for (ll i = 0; i < n-3; i++) {
string h = "";
h.pb(s[i]);
h.pb(s[i+1]);
h.pb(s[i+2]);
h.pb(s[i+3]);
mp[h]++;
}
ll q;
cin >> q;
while (q--) {
ll idx;
char c;
cin >> idx >> c;
idx--;
if (s[idx] == c) {
mp["1100"] ? cout << "YES" << endl : cout << "NO" << endl;
} else {
for (ll i = idx-3; i <= idx; i++) {
if (i < 0) {
continue;
} else if (i >= n-3) {
continue;
} else {
string p = "";
p.pb(s[i]);
p.pb(s[i+1]);
p.pb(s[i+2]);
p.pb(s[i+3]);
mp[p]--;
}
}
s[idx] = c;
for (ll i = idx-3; i <= idx; i++) {
if (i < 0) {
continue;
} else if (i >= n-3) {
continue;
} else {
string p = "";
p.pb(s[i]);
p.pb(s[i+1]);
p.pb(s[i+2]);
p.pb(s[i+3]);
mp[p]++;
}
}
mp["1100"] ? cout << "YES" << endl : cout << "NO" << endl;
}
}
}
}