Submission #533808

#TimeUsernameProblemLanguageResultExecution timeMemory
533808RaresFelixCrossing (JOI21_crossing)C++17
26 / 100
1746 ms82288 KiB
#include <bits/stdc++.h> 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 207171 int n, q; vector<int> C[9], P; struct SL { vector<int> B; int Vl[4 * MN], Eq[4 * MN], Lz[4 * MN]; void bld(int u, int s, int d) { 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> B) : B(std::move(B)){ 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 >> 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]))); cin >> q; rd(P); for(int i = 0; i < 7; ++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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...