답안 #533820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533820 2022-03-07T11:16:57 Z RaresFelix Crossing (JOI21_crossing) C++17
100 / 100
1930 ms 191408 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#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 V[4 * MN], E[4 * MN], L[4 * MN];
    void bd(int u, int s, int d) {
        L[u] = V[u] = E[u] = 0;
        if(s == d) {
            V[u] = B[s];
            E[u] = (B[s] == P[s]);
            return;
        }
        bd(u * 2, s, (s + d) / 2);
        bd(u * 2 + 1, (s + d) / 2 + 1, d);
        V[u] = ((V[u * 2] == V[u * 2 + 1]) ? V[u * 2] : -1);
        E[u] = E[u * 2] && E[u * 2 + 1];
    }
    SL(vector<int> E) : B(move(E)) { bd(1, 0, n-1); }
    void pp(int u, int s, int d) {
        if(!L[u]) return;
        int v = L[u] - 3;
        E[u] = (V[u] == v);
        if(s != d)
            L[u * 2] = L[u * 2 + 1] = L[u];
        L[u] = 0;
    }
    void pset(int l, int r, int v, int u, int s, int d) {
        pp(u, s, d);
        if(r < s || d < l) return;
        if(l <= s && d <= r) {
            L[u] = v + 3;
            pp(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);
        V[u] = ((V[u * 2] == V[u * 2 + 1] )? V[u * 2] : -1);
        E[u] = E[u * 2] && E[u * 2 + 1];
    }
};
vector<SL> SS;
void af() {
    int ok = 0;
    for(auto &it : SS) ok |= it.E[1];
    cout << (ok ? "Yes\n" : "No\n");
}
void rd(vi &C) {
    string w;
    cin >> w;
    for(auto it : w) C.pb(LT(it));
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    char c;
    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].pb(c = CMB(C[i][k], C[j][k])), C[3 + nr].pb(CMB(c, C[3 - i - j][k]));
    cin >> q;
    rd(P);
    for(int i = 0; i < 9; ++i) SS.emplace_back(C[i]);
    af();
    for(int i = 1, l, r; i <= q; ++i) {
        cin >> l >> r >> c;
        --l, --r;
        for(auto &it : SS)
            it.pset(l, r, LT(c), 1, 0, n - 1);
        af();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 145424 KB Output is correct
2 Correct 336 ms 145432 KB Output is correct
3 Correct 325 ms 145348 KB Output is correct
4 Correct 284 ms 145420 KB Output is correct
5 Correct 275 ms 145432 KB Output is correct
6 Correct 272 ms 145428 KB Output is correct
7 Correct 279 ms 145332 KB Output is correct
8 Correct 288 ms 145500 KB Output is correct
9 Correct 291 ms 145484 KB Output is correct
10 Correct 295 ms 145400 KB Output is correct
11 Correct 294 ms 145344 KB Output is correct
12 Correct 280 ms 145428 KB Output is correct
13 Correct 283 ms 145448 KB Output is correct
14 Correct 279 ms 145344 KB Output is correct
15 Correct 293 ms 145484 KB Output is correct
16 Correct 287 ms 145336 KB Output is correct
17 Correct 288 ms 145520 KB Output is correct
18 Correct 295 ms 145304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 145424 KB Output is correct
2 Correct 336 ms 145432 KB Output is correct
3 Correct 325 ms 145348 KB Output is correct
4 Correct 284 ms 145420 KB Output is correct
5 Correct 275 ms 145432 KB Output is correct
6 Correct 272 ms 145428 KB Output is correct
7 Correct 279 ms 145332 KB Output is correct
8 Correct 288 ms 145500 KB Output is correct
9 Correct 291 ms 145484 KB Output is correct
10 Correct 295 ms 145400 KB Output is correct
11 Correct 294 ms 145344 KB Output is correct
12 Correct 280 ms 145428 KB Output is correct
13 Correct 283 ms 145448 KB Output is correct
14 Correct 279 ms 145344 KB Output is correct
15 Correct 293 ms 145484 KB Output is correct
16 Correct 287 ms 145336 KB Output is correct
17 Correct 288 ms 145520 KB Output is correct
18 Correct 295 ms 145304 KB Output is correct
19 Correct 1704 ms 191284 KB Output is correct
20 Correct 1326 ms 191336 KB Output is correct
21 Correct 1145 ms 190416 KB Output is correct
22 Correct 1120 ms 188992 KB Output is correct
23 Correct 578 ms 148272 KB Output is correct
24 Correct 555 ms 148392 KB Output is correct
25 Correct 1207 ms 191316 KB Output is correct
26 Correct 1239 ms 191360 KB Output is correct
27 Correct 1422 ms 191352 KB Output is correct
28 Correct 1433 ms 191308 KB Output is correct
29 Correct 1351 ms 190924 KB Output is correct
30 Correct 581 ms 148188 KB Output is correct
31 Correct 1395 ms 191316 KB Output is correct
32 Correct 1438 ms 190216 KB Output is correct
33 Correct 527 ms 148276 KB Output is correct
34 Correct 1477 ms 191360 KB Output is correct
35 Correct 1049 ms 187760 KB Output is correct
36 Correct 507 ms 148228 KB Output is correct
37 Correct 515 ms 148256 KB Output is correct
38 Correct 1115 ms 191392 KB Output is correct
39 Correct 606 ms 191336 KB Output is correct
40 Correct 1065 ms 170708 KB Output is correct
41 Correct 1930 ms 191316 KB Output is correct
42 Correct 184 ms 191408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 145424 KB Output is correct
2 Correct 336 ms 145432 KB Output is correct
3 Correct 325 ms 145348 KB Output is correct
4 Correct 284 ms 145420 KB Output is correct
5 Correct 275 ms 145432 KB Output is correct
6 Correct 272 ms 145428 KB Output is correct
7 Correct 279 ms 145332 KB Output is correct
8 Correct 288 ms 145500 KB Output is correct
9 Correct 291 ms 145484 KB Output is correct
10 Correct 295 ms 145400 KB Output is correct
11 Correct 294 ms 145344 KB Output is correct
12 Correct 280 ms 145428 KB Output is correct
13 Correct 283 ms 145448 KB Output is correct
14 Correct 279 ms 145344 KB Output is correct
15 Correct 293 ms 145484 KB Output is correct
16 Correct 287 ms 145336 KB Output is correct
17 Correct 288 ms 145520 KB Output is correct
18 Correct 295 ms 145304 KB Output is correct
19 Correct 331 ms 145436 KB Output is correct
20 Correct 345 ms 145384 KB Output is correct
21 Correct 293 ms 145332 KB Output is correct
22 Correct 273 ms 145324 KB Output is correct
23 Correct 301 ms 145440 KB Output is correct
24 Correct 291 ms 145448 KB Output is correct
25 Correct 297 ms 145396 KB Output is correct
26 Correct 278 ms 145432 KB Output is correct
27 Correct 292 ms 145376 KB Output is correct
28 Correct 270 ms 145448 KB Output is correct
29 Correct 294 ms 145404 KB Output is correct
30 Correct 260 ms 145448 KB Output is correct
31 Correct 301 ms 145356 KB Output is correct
32 Correct 284 ms 145388 KB Output is correct
33 Correct 306 ms 145372 KB Output is correct
34 Correct 267 ms 145476 KB Output is correct
35 Correct 287 ms 145440 KB Output is correct
36 Correct 297 ms 145448 KB Output is correct
37 Correct 293 ms 145468 KB Output is correct
38 Correct 305 ms 145416 KB Output is correct
39 Correct 286 ms 145476 KB Output is correct
40 Correct 296 ms 145360 KB Output is correct
41 Correct 286 ms 145368 KB Output is correct
42 Correct 294 ms 145468 KB Output is correct
43 Correct 278 ms 145444 KB Output is correct
44 Correct 293 ms 145384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 145424 KB Output is correct
2 Correct 336 ms 145432 KB Output is correct
3 Correct 325 ms 145348 KB Output is correct
4 Correct 284 ms 145420 KB Output is correct
5 Correct 275 ms 145432 KB Output is correct
6 Correct 272 ms 145428 KB Output is correct
7 Correct 279 ms 145332 KB Output is correct
8 Correct 288 ms 145500 KB Output is correct
9 Correct 291 ms 145484 KB Output is correct
10 Correct 295 ms 145400 KB Output is correct
11 Correct 294 ms 145344 KB Output is correct
12 Correct 280 ms 145428 KB Output is correct
13 Correct 283 ms 145448 KB Output is correct
14 Correct 279 ms 145344 KB Output is correct
15 Correct 293 ms 145484 KB Output is correct
16 Correct 287 ms 145336 KB Output is correct
17 Correct 288 ms 145520 KB Output is correct
18 Correct 295 ms 145304 KB Output is correct
19 Correct 1704 ms 191284 KB Output is correct
20 Correct 1326 ms 191336 KB Output is correct
21 Correct 1145 ms 190416 KB Output is correct
22 Correct 1120 ms 188992 KB Output is correct
23 Correct 578 ms 148272 KB Output is correct
24 Correct 555 ms 148392 KB Output is correct
25 Correct 1207 ms 191316 KB Output is correct
26 Correct 1239 ms 191360 KB Output is correct
27 Correct 1422 ms 191352 KB Output is correct
28 Correct 1433 ms 191308 KB Output is correct
29 Correct 1351 ms 190924 KB Output is correct
30 Correct 581 ms 148188 KB Output is correct
31 Correct 1395 ms 191316 KB Output is correct
32 Correct 1438 ms 190216 KB Output is correct
33 Correct 527 ms 148276 KB Output is correct
34 Correct 1477 ms 191360 KB Output is correct
35 Correct 1049 ms 187760 KB Output is correct
36 Correct 507 ms 148228 KB Output is correct
37 Correct 515 ms 148256 KB Output is correct
38 Correct 1115 ms 191392 KB Output is correct
39 Correct 606 ms 191336 KB Output is correct
40 Correct 1065 ms 170708 KB Output is correct
41 Correct 1930 ms 191316 KB Output is correct
42 Correct 184 ms 191408 KB Output is correct
43 Correct 331 ms 145436 KB Output is correct
44 Correct 345 ms 145384 KB Output is correct
45 Correct 293 ms 145332 KB Output is correct
46 Correct 273 ms 145324 KB Output is correct
47 Correct 301 ms 145440 KB Output is correct
48 Correct 291 ms 145448 KB Output is correct
49 Correct 297 ms 145396 KB Output is correct
50 Correct 278 ms 145432 KB Output is correct
51 Correct 292 ms 145376 KB Output is correct
52 Correct 270 ms 145448 KB Output is correct
53 Correct 294 ms 145404 KB Output is correct
54 Correct 260 ms 145448 KB Output is correct
55 Correct 301 ms 145356 KB Output is correct
56 Correct 284 ms 145388 KB Output is correct
57 Correct 306 ms 145372 KB Output is correct
58 Correct 267 ms 145476 KB Output is correct
59 Correct 287 ms 145440 KB Output is correct
60 Correct 297 ms 145448 KB Output is correct
61 Correct 293 ms 145468 KB Output is correct
62 Correct 305 ms 145416 KB Output is correct
63 Correct 286 ms 145476 KB Output is correct
64 Correct 296 ms 145360 KB Output is correct
65 Correct 286 ms 145368 KB Output is correct
66 Correct 294 ms 145468 KB Output is correct
67 Correct 278 ms 145444 KB Output is correct
68 Correct 293 ms 145384 KB Output is correct
69 Correct 1510 ms 188884 KB Output is correct
70 Correct 1326 ms 191292 KB Output is correct
71 Correct 543 ms 148376 KB Output is correct
72 Correct 531 ms 148388 KB Output is correct
73 Correct 510 ms 148432 KB Output is correct
74 Correct 1098 ms 188796 KB Output is correct
75 Correct 511 ms 148360 KB Output is correct
76 Correct 1300 ms 191112 KB Output is correct
77 Correct 1183 ms 188664 KB Output is correct
78 Correct 536 ms 148320 KB Output is correct
79 Correct 505 ms 148324 KB Output is correct
80 Correct 1046 ms 186884 KB Output is correct
81 Correct 512 ms 148272 KB Output is correct
82 Correct 1260 ms 191304 KB Output is correct
83 Correct 1165 ms 190164 KB Output is correct
84 Correct 525 ms 148276 KB Output is correct
85 Correct 505 ms 148276 KB Output is correct
86 Correct 1262 ms 187596 KB Output is correct
87 Correct 1447 ms 191100 KB Output is correct
88 Correct 576 ms 148284 KB Output is correct
89 Correct 1252 ms 189400 KB Output is correct
90 Correct 1392 ms 191076 KB Output is correct
91 Correct 579 ms 148348 KB Output is correct
92 Correct 1091 ms 187340 KB Output is correct
93 Correct 535 ms 148444 KB Output is correct
94 Correct 501 ms 148276 KB Output is correct
95 Correct 590 ms 148404 KB Output is correct
96 Correct 1178 ms 191188 KB Output is correct
97 Correct 605 ms 191164 KB Output is correct
98 Correct 1077 ms 170676 KB Output is correct
99 Correct 1802 ms 191168 KB Output is correct
100 Correct 180 ms 190940 KB Output is correct