#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"
const int maxn = 2e5 + 100;
const ll INF = (ll)1e18 + 100;
const int inf = 1e7 + 100;
const ll MOD = 1e9 + 7;
const int maxl = 16;
const ll P = 31;
int n;
struct asd{
int f, ok;
} d[maxn * 4];
int t[maxn * 4];
int f(char c){
if(c == 'J') return 0;
if(c == 'O') return 1;
return 2;
}
asd ff(asd a, asd b){
if(a.f != b.f) return {-1, a.ok & b.ok};
return {a.f, a.ok & b.ok};
}
void build(int v = 1, int tl = 1, int tr = n){
t[v] = -1;
if(tl == tr){
char c; cin >> c;
d[v] = {f(c), 1};
} else{
int mid = (tl + tr) >> 1;
build(v<<1, tl, mid);
build(v<<1|1, mid+1, tr);
d[v] = ff(d[v<<1], d[v<<1|1]);
}
}
void pre(int v, int x){
d[v] = {d[v].f, d[v].f == x};
t[v] = x;
} void push(int v, int tl, int tr){
if(tl == tr || t[v] == -1) return;
pre(v<<1, t[v]); pre(v<<1|1, t[v]);
t[v] = -1;
}
void upd(int l, int r, int x, int v = 1, int tl = 1, int tr = n){
if(tl > r || tr < l) return;
if(l <= tl && tr <= r) pre(v, x);
else{ push(v, tl, tr);
int mid = (tl + tr) >> 1;
upd(l, r, x, v<<1, tl, mid);
upd(l, r, x, v<<1|1, mid+1, tr);
d[v] = ff(d[v<<1], d[v<<1|1]);
}
}
void ans(){
if(d[1].ok) cout << "Yes\n";
else cout << "No\n";
}
void test(){
cin >> n; build();
for(int i = 1; i <= n * 2; i++){
char c; cin >> c;
} int q; cin >> q;
for(int i = 1; i <= n; i++){
char c; cin >> c;
upd(i, i, f(c));
} ans(); while(q--){
int l, r; char c;
cin >> l >> r >> c;
upd(l, r, f(c));
ans();
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
srand(time(0));
int t = 1;
while(t--) test();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |