답안 #550754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550754 2022-04-19T03:17:41 Z tht2005 Crossing (JOI21_crossing) C++17
100 / 100
2013 ms 16516 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 200005;
int n;
char s[9][N], t[N];

void add(char* r, char* a, char* b) {
    for(int i = 0; i < n; ++i) {
        if(a[i] == b[i]) {
            r[i] = a[i];
        }
        else {
            r[i] = 'J' + 'O' + 'I' - a[i] - b[i];
        }
    }
}

const int N_ = 262144;
char st[9][N_ << 1], lz[N_ << 1];
bool res[9][N_ << 1];
void build(int x, int l, int r) {
    lz[x] = 0;
    if(l == r) {
        for(int i = 0; i < 9; ++i) {
            st[i][x] = s[i][l];
            res[i][x] = (s[i][l] == t[l]);
        }
    }
    else {
        int m = (l + r) >> 1;
        build(x << 1, l, m);
        build(x << 1 | 1, m + 1, r);
        for(int i = 0; i < 9; ++i) {
            st[i][x] = (st[i][x << 1] == st[i][x << 1 | 1]) ? st[i][x << 1] : 0;
            res[i][x] = res[i][x << 1] && res[i][x << 1 | 1];
        }
    }
}
void push(int x, int l, int r) {
    if(lz[x]) {
        for(int i = 0; i < 9; ++i) {
            res[i][x] = (st[i][x] == lz[x]);
        }
        if(l != r) {
            lz[x << 1] = lz[x << 1 | 1] = lz[x];
        }
        lz[x] = 0;
    }
}
void update(int x, int l, int r, int ql, int qr, char d) {
    push(x, l, r); if(r < ql || qr < l) return;
    if(ql <= l && r <= qr) {
        lz[x] = d;
        push(x, l, r);
    }
    else {
        int m = (l + r) >> 1;
        update(x << 1, l, m, ql, qr, d);
        update(x << 1 | 1, m + 1, r, ql, qr, d);
        for(int i = 0; i < 9; ++i) {
            res[i][x] = res[i][x << 1] && res[i][x << 1 | 1];
        }
    }
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < 3; ++i) {
        scanf("%s", s[i]);
    }
    add(s[3], s[0], s[1]);
    add(s[4], s[0], s[2]);
    add(s[5], s[1], s[2]);
    add(s[6], s[3], s[2]);
    add(s[7], s[4], s[1]);
    add(s[8], s[5], s[0]);
    int q;
    scanf("%d %s", &q, t);
    build(1, 0, n - 1);
    bool ok = 0;
    for(int i = 0; i < 9; ++i) {
        if(res[i][1]) {
            ok = 1;
            break;
        }
    }
    puts(ok ? "Yes" : "No");
    while(q--) {
        int l, r;
        char c;
        scanf("%d %d %c", &l, &r, &c);
        update(1, 0, n - 1, l - 1, r - 1, c);
        ok = 0;
        for(int i = 0; i < 9; ++i) {
            if(res[i][1]) {
                ok = 1;
                break;
            }
        }
        puts(ok ? "Yes" : "No");
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         scanf("%s", s[i]);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |     scanf("%d %s", &q, t);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:93:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         scanf("%d %d %c", &l, &r, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 2288 KB Output is correct
2 Correct 347 ms 2544 KB Output is correct
3 Correct 440 ms 2548 KB Output is correct
4 Correct 251 ms 2420 KB Output is correct
5 Correct 236 ms 2420 KB Output is correct
6 Correct 247 ms 2388 KB Output is correct
7 Correct 240 ms 2568 KB Output is correct
8 Correct 271 ms 2428 KB Output is correct
9 Correct 258 ms 2524 KB Output is correct
10 Correct 249 ms 2480 KB Output is correct
11 Correct 241 ms 2528 KB Output is correct
12 Correct 237 ms 2520 KB Output is correct
13 Correct 250 ms 2480 KB Output is correct
14 Correct 236 ms 2512 KB Output is correct
15 Correct 261 ms 2524 KB Output is correct
16 Correct 227 ms 2540 KB Output is correct
17 Correct 263 ms 2476 KB Output is correct
18 Correct 422 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 2288 KB Output is correct
2 Correct 347 ms 2544 KB Output is correct
3 Correct 440 ms 2548 KB Output is correct
4 Correct 251 ms 2420 KB Output is correct
5 Correct 236 ms 2420 KB Output is correct
6 Correct 247 ms 2388 KB Output is correct
7 Correct 240 ms 2568 KB Output is correct
8 Correct 271 ms 2428 KB Output is correct
9 Correct 258 ms 2524 KB Output is correct
10 Correct 249 ms 2480 KB Output is correct
11 Correct 241 ms 2528 KB Output is correct
12 Correct 237 ms 2520 KB Output is correct
13 Correct 250 ms 2480 KB Output is correct
14 Correct 236 ms 2512 KB Output is correct
15 Correct 261 ms 2524 KB Output is correct
16 Correct 227 ms 2540 KB Output is correct
17 Correct 263 ms 2476 KB Output is correct
18 Correct 422 ms 2640 KB Output is correct
19 Correct 1433 ms 16272 KB Output is correct
20 Correct 1686 ms 16232 KB Output is correct
21 Correct 539 ms 15920 KB Output is correct
22 Correct 575 ms 15500 KB Output is correct
23 Correct 374 ms 3948 KB Output is correct
24 Correct 370 ms 4184 KB Output is correct
25 Correct 546 ms 16288 KB Output is correct
26 Correct 713 ms 16224 KB Output is correct
27 Correct 910 ms 16208 KB Output is correct
28 Correct 903 ms 16272 KB Output is correct
29 Correct 832 ms 16064 KB Output is correct
30 Correct 503 ms 4048 KB Output is correct
31 Correct 842 ms 16368 KB Output is correct
32 Correct 783 ms 15912 KB Output is correct
33 Correct 410 ms 3992 KB Output is correct
34 Correct 851 ms 16240 KB Output is correct
35 Correct 498 ms 15280 KB Output is correct
36 Correct 342 ms 4056 KB Output is correct
37 Correct 370 ms 3964 KB Output is correct
38 Correct 1529 ms 15992 KB Output is correct
39 Correct 559 ms 16272 KB Output is correct
40 Correct 547 ms 10436 KB Output is correct
41 Correct 2013 ms 16516 KB Output is correct
42 Correct 149 ms 15644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 2288 KB Output is correct
2 Correct 347 ms 2544 KB Output is correct
3 Correct 440 ms 2548 KB Output is correct
4 Correct 251 ms 2420 KB Output is correct
5 Correct 236 ms 2420 KB Output is correct
6 Correct 247 ms 2388 KB Output is correct
7 Correct 240 ms 2568 KB Output is correct
8 Correct 271 ms 2428 KB Output is correct
9 Correct 258 ms 2524 KB Output is correct
10 Correct 249 ms 2480 KB Output is correct
11 Correct 241 ms 2528 KB Output is correct
12 Correct 237 ms 2520 KB Output is correct
13 Correct 250 ms 2480 KB Output is correct
14 Correct 236 ms 2512 KB Output is correct
15 Correct 261 ms 2524 KB Output is correct
16 Correct 227 ms 2540 KB Output is correct
17 Correct 263 ms 2476 KB Output is correct
18 Correct 422 ms 2640 KB Output is correct
19 Correct 343 ms 2356 KB Output is correct
20 Correct 465 ms 2392 KB Output is correct
21 Correct 242 ms 2516 KB Output is correct
22 Correct 218 ms 2404 KB Output is correct
23 Correct 235 ms 2432 KB Output is correct
24 Correct 248 ms 2524 KB Output is correct
25 Correct 262 ms 2636 KB Output is correct
26 Correct 227 ms 2336 KB Output is correct
27 Correct 258 ms 2540 KB Output is correct
28 Correct 220 ms 2312 KB Output is correct
29 Correct 259 ms 2528 KB Output is correct
30 Correct 210 ms 2388 KB Output is correct
31 Correct 237 ms 2436 KB Output is correct
32 Correct 243 ms 2512 KB Output is correct
33 Correct 249 ms 2528 KB Output is correct
34 Correct 237 ms 2376 KB Output is correct
35 Correct 235 ms 2620 KB Output is correct
36 Correct 254 ms 2548 KB Output is correct
37 Correct 238 ms 2548 KB Output is correct
38 Correct 255 ms 2492 KB Output is correct
39 Correct 229 ms 2552 KB Output is correct
40 Correct 255 ms 2520 KB Output is correct
41 Correct 231 ms 2488 KB Output is correct
42 Correct 253 ms 2460 KB Output is correct
43 Correct 233 ms 2504 KB Output is correct
44 Correct 259 ms 2516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 2288 KB Output is correct
2 Correct 347 ms 2544 KB Output is correct
3 Correct 440 ms 2548 KB Output is correct
4 Correct 251 ms 2420 KB Output is correct
5 Correct 236 ms 2420 KB Output is correct
6 Correct 247 ms 2388 KB Output is correct
7 Correct 240 ms 2568 KB Output is correct
8 Correct 271 ms 2428 KB Output is correct
9 Correct 258 ms 2524 KB Output is correct
10 Correct 249 ms 2480 KB Output is correct
11 Correct 241 ms 2528 KB Output is correct
12 Correct 237 ms 2520 KB Output is correct
13 Correct 250 ms 2480 KB Output is correct
14 Correct 236 ms 2512 KB Output is correct
15 Correct 261 ms 2524 KB Output is correct
16 Correct 227 ms 2540 KB Output is correct
17 Correct 263 ms 2476 KB Output is correct
18 Correct 422 ms 2640 KB Output is correct
19 Correct 1433 ms 16272 KB Output is correct
20 Correct 1686 ms 16232 KB Output is correct
21 Correct 539 ms 15920 KB Output is correct
22 Correct 575 ms 15500 KB Output is correct
23 Correct 374 ms 3948 KB Output is correct
24 Correct 370 ms 4184 KB Output is correct
25 Correct 546 ms 16288 KB Output is correct
26 Correct 713 ms 16224 KB Output is correct
27 Correct 910 ms 16208 KB Output is correct
28 Correct 903 ms 16272 KB Output is correct
29 Correct 832 ms 16064 KB Output is correct
30 Correct 503 ms 4048 KB Output is correct
31 Correct 842 ms 16368 KB Output is correct
32 Correct 783 ms 15912 KB Output is correct
33 Correct 410 ms 3992 KB Output is correct
34 Correct 851 ms 16240 KB Output is correct
35 Correct 498 ms 15280 KB Output is correct
36 Correct 342 ms 4056 KB Output is correct
37 Correct 370 ms 3964 KB Output is correct
38 Correct 1529 ms 15992 KB Output is correct
39 Correct 559 ms 16272 KB Output is correct
40 Correct 547 ms 10436 KB Output is correct
41 Correct 2013 ms 16516 KB Output is correct
42 Correct 149 ms 15644 KB Output is correct
43 Correct 343 ms 2356 KB Output is correct
44 Correct 465 ms 2392 KB Output is correct
45 Correct 242 ms 2516 KB Output is correct
46 Correct 218 ms 2404 KB Output is correct
47 Correct 235 ms 2432 KB Output is correct
48 Correct 248 ms 2524 KB Output is correct
49 Correct 262 ms 2636 KB Output is correct
50 Correct 227 ms 2336 KB Output is correct
51 Correct 258 ms 2540 KB Output is correct
52 Correct 220 ms 2312 KB Output is correct
53 Correct 259 ms 2528 KB Output is correct
54 Correct 210 ms 2388 KB Output is correct
55 Correct 237 ms 2436 KB Output is correct
56 Correct 243 ms 2512 KB Output is correct
57 Correct 249 ms 2528 KB Output is correct
58 Correct 237 ms 2376 KB Output is correct
59 Correct 235 ms 2620 KB Output is correct
60 Correct 254 ms 2548 KB Output is correct
61 Correct 238 ms 2548 KB Output is correct
62 Correct 255 ms 2492 KB Output is correct
63 Correct 229 ms 2552 KB Output is correct
64 Correct 255 ms 2520 KB Output is correct
65 Correct 231 ms 2488 KB Output is correct
66 Correct 253 ms 2460 KB Output is correct
67 Correct 233 ms 2504 KB Output is correct
68 Correct 259 ms 2516 KB Output is correct
69 Correct 1311 ms 15668 KB Output is correct
70 Correct 1635 ms 16184 KB Output is correct
71 Correct 351 ms 4080 KB Output is correct
72 Correct 376 ms 3964 KB Output is correct
73 Correct 344 ms 4056 KB Output is correct
74 Correct 561 ms 15572 KB Output is correct
75 Correct 338 ms 4084 KB Output is correct
76 Correct 547 ms 16256 KB Output is correct
77 Correct 635 ms 15612 KB Output is correct
78 Correct 372 ms 3988 KB Output is correct
79 Correct 382 ms 4044 KB Output is correct
80 Correct 528 ms 15232 KB Output is correct
81 Correct 344 ms 3944 KB Output is correct
82 Correct 572 ms 16388 KB Output is correct
83 Correct 630 ms 15984 KB Output is correct
84 Correct 349 ms 3952 KB Output is correct
85 Correct 378 ms 4108 KB Output is correct
86 Correct 885 ms 15432 KB Output is correct
87 Correct 859 ms 16284 KB Output is correct
88 Correct 473 ms 4052 KB Output is correct
89 Correct 729 ms 15680 KB Output is correct
90 Correct 780 ms 16244 KB Output is correct
91 Correct 449 ms 4004 KB Output is correct
92 Correct 482 ms 15292 KB Output is correct
93 Correct 356 ms 4060 KB Output is correct
94 Correct 363 ms 4044 KB Output is correct
95 Correct 357 ms 4136 KB Output is correct
96 Correct 1509 ms 16084 KB Output is correct
97 Correct 506 ms 16260 KB Output is correct
98 Correct 570 ms 10388 KB Output is correct
99 Correct 1819 ms 16444 KB Output is correct
100 Correct 157 ms 15824 KB Output is correct