This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define LT(x) ((x) == 'I' ? 2 : (x) == 'O')
#define CMB(x, y) (((x) == (y)) ? (x) : (3 - ((x) + (y))))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MN 257171
int n, q;
vector<int> C[10], P;
struct SL {
vector<int> B;
int Vl[4 * MN], Eq[4 * MN], Lz[4 * MN];
void bld(int u, int s, int d) {
Lz[u] = Vl[u] = Eq[u] = 0;
if(s == d) {
Vl[u] = B[s];
Eq[u] = (B[s] == P[s]);
return;
}
bld(u * 2, s, (s + d) / 2);
bld(u * 2 + 1, (s + d) / 2 + 1, d);
Vl[u] = ((Vl[u * 2] == Vl[u * 2 + 1]) ? Vl[u * 2] : -1);
Eq[u] = Eq[u * 2] && Eq[u * 2 + 1];
}
SL(vector<int> E) : B(std::move(E)){
bld(1, 0, n-1);
}
void prp(int u, int s, int d) {
if(!Lz[u]) return;
int v = Lz[u] - 3;
Eq[u] = (Vl[u] == v);
if(s != d)
Lz[u * 2] = Lz[u * 2 + 1] = Lz[u];
Lz[u] = 0;
}
void pset(int l, int r, int v, int u, int s, int d) {
prp(u, s, d);
if(r < s || d < l) return;
if(l <= s && d <= r) {
Lz[u] = v + 3;
prp(u, s, d);
return;
}
pset(l, r, v, u * 2, s, (s + d) / 2);
pset(l, r, v, u * 2 + 1, (s + d) / 2 + 1, d);
Vl[u] = ((Vl[u * 2] == Vl[u * 2 + 1] )? Vl[u * 2] : -1);
Eq[u] = Eq[u * 2] && Eq[u * 2 + 1];
}
};
vector<SL> SS;
void af() {
int ok = 0;
for(auto &it : SS) ok |= it.Eq[1];
cout << (ok ? "Yes\n" : "No\n");
}
void rd(vi &C) {
string w;
cin >> w;
for(auto it : w) C.push_back(LT(it));
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n;
for(int i = 0; i < 3; ++i) rd(C[i]);
int nr = 2;
for(int i = 0; i < 3; ++i)
for(int j = i + 1; j < 3; ++j)
for(int k = !(++nr); k < n; ++k) C[nr].push_back(CMB(C[i][k], C[j][k]));
for(int i = 0; i < n; ++i) C[6].push_back(CMB(C[0][i], CMB(C[1][i], C[2][i])));
for(int i = 7; i <= 9; ++i)
for(int k = 0; k < n; ++k) C[i].push_back(CMB(C[i-4][k], C[i-7][k]));
cin >> q;
rd(P);
for(int i = 0; i < 10; ++i)
SS.emplace_back(C[i]);
af();
for(int i = 1, l, r; i <= q; ++i) {
char c;
cin >> l >> r >> c;
--l, --r;
for(auto &it : SS)
it.pset(l, r, LT(c), 1, 0, n - 1);
af();
}
return 0;
}
# | 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... |