#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int mp[202];
string x, y;
struct Seg{
pair<int, bool> tree[800800];
int lazy[800800];
pair<int, bool> combine(pair<int, bool> z, pair<int, bool> w){
pair<int, bool> ret = {0, 0};
if (z.first==w.first) ret.first = z.first;
ret.second = z.second&w.second;
return ret;
}
void init(int i, int l, int r){
if (l!=r){
int m = (l+r)>>1;
init(i<<1, l, m); init(i<<1|1, m+1, r);
tree[i] = combine(tree[i<<1], tree[i<<1|1]);
}
else{
tree[i] = {mp[x[l]], 0};
if (x[l]==y[l]) tree[i].second = 1;
}
}
void propagate(int i, int l, int r){
if (!lazy[i]) return;
if (tree[i].first==lazy[i]) tree[i].second = 1;
if (l!=r){
lazy[i<<1] = lazy[i], lazy[i<<1|1] = lazy[i];
}
lazy[i] = 0;
}
void update(int i, int l, int r, int s, int e, int val){
propagate(i, l, r);
if (r<s || e<l) return;
if (s<=l && r<=e){
lazy[i] = val; propagate(i, l, r);
return;
}
int m = (l+r)>>1;
update(i<<1, l, m, s, e, val);
update(i<<1|1, m+1, r, s, e, val);
tree[i] = combine(tree[i<<1], tree[i<<1|1]);
}
}tree;
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
mp['J'] = 1, mp['O'] = 2, mp['I'] = 3;
int n, q;
cin >> n;
cin >> x >> x >> x;
cin >> q;
cin >> y;
tree.init(1, 0, n-1);
if (tree.tree[1].second) cout << "Yes\n";
else cout << "No\n";
while(q--){
int l, r;
char tmp;
cin >> l >> r >> tmp;
tree.update(1, 1, n, l, r, mp[tmp]);
if (tree.tree[1].second) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
Compilation message
Main.cpp: In member function 'void Seg::init(int, int, int)':
Main.cpp:23:31: warning: array subscript has type 'char' [-Wchar-subscripts]
23 | tree[i] = {mp[x[l]], 0};
| ^
Main.cpp: In function 'int main()':
Main.cpp:66:39: warning: array subscript has type 'char' [-Wchar-subscripts]
66 | tree.update(1, 1, n, l, r, mp[tmp]);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
7264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
7264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
7264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
7264 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |