답안 #539134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539134 2022-03-18T13:05:35 Z kianaRZV Crossing (JOI21_crossing) C++14
26 / 100
489 ms 52120 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int maxn = 3e5 + 10, mod = 1e9 + 7;
int n, q;
int a[maxn], b[maxn], c[maxn], d[maxn], lazy[maxn << 2], seg[maxn << 2][3][3];

int get(char c) {
    if (c == 'J') return 0;
    if (c == 'O') return 1;
    return 2;
}

void init(int id, int qv) {
    lazy[id] = qv;
    for (int i = 0; i < 3; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++)
            cnt += seg[id][i][j], seg[id][i][j] = 0;
        seg[id][i][qv] = cnt;
    }
}

void shift(int id) {
    if (lazy[id] == -1) return;
    init(2 * id + 1, lazy[id]);
    init(2 * id + 2, lazy[id]);
    lazy[id] = -1;
}

void build(int id, int l, int r) {
    lazy[id] = -1;
    if (r - l < 2) {
        seg[id][a[l]][d[l]]++;
        return;
    }
    int mid = l + r >> 1;
    build(2 * id + 1, l, mid);
    build(2 * id + 2, mid, r);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            seg[id][i][j] = seg[2 * id + 1][i][j] + seg[2 * id + 2][i][j];
}

void update(int id, int l, int r, int ql, int qr, int qv) {
    if (l >= qr || ql >= r)
        return;
    if (ql <= l && r <= qr)
        return init(id, qv);
    int mid = l + r >> 1;
    shift(id);
    update(2 * id + 1, l, mid, ql, qr, qv);
    update(2 * id + 2, mid, r, ql, qr, qv);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            seg[id][i][j] = seg[2 * id + 1][i][j] + seg[2 * id + 2][i][j];
}

void check() {
    cout << (seg[0][0][0] + seg[0][1][1] + seg[0][2][2] == n? "Yes\n": "No\n");
}

void read_input() {
    cin >> n;
    char x;
    for (int i = 0; i < n; i++)
        cin >> x, a[i] = get(x);
    for (int i = 0; i < n; i++)
        cin >> x, b[i] = get(x);
    for (int i = 0; i < n; i++)
        cin >> x, c[i] = get(x);
    cin >> q;
    for (int i = 0; i < n; i++)
        cin >> x, d[i] = get(x);
}

void solve() {
    build(0, 0, n);
    check();
    while(q--) {
        int l, r;
        char c;
        cin >> l >> r >> c;
        update(0, 0, n, --l, r, get(c));
        check();
    }
}

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    read_input(), solve();
}
/*   /\_/\
    (= ._.)
    / >0  \>1
*/

Compilation message

Main.cpp: In function 'void build(long long int, long long int, long long int)':
Main.cpp:38:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |     int mid = l + r >> 1;
      |               ~~^~~
Main.cpp: In function 'void update(long long int, long long int, long long int, long long int, long long int, long long int)':
Main.cpp:51:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |     int mid = l + r >> 1;
      |               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 916 KB Output is correct
2 Correct 94 ms 2508 KB Output is correct
3 Correct 93 ms 2384 KB Output is correct
4 Correct 81 ms 2380 KB Output is correct
5 Correct 71 ms 2324 KB Output is correct
6 Correct 69 ms 2316 KB Output is correct
7 Correct 66 ms 2508 KB Output is correct
8 Correct 78 ms 2404 KB Output is correct
9 Correct 92 ms 2468 KB Output is correct
10 Correct 82 ms 2392 KB Output is correct
11 Correct 75 ms 2424 KB Output is correct
12 Correct 78 ms 2436 KB Output is correct
13 Correct 88 ms 2400 KB Output is correct
14 Correct 76 ms 2488 KB Output is correct
15 Correct 70 ms 2428 KB Output is correct
16 Correct 78 ms 2508 KB Output is correct
17 Correct 76 ms 2480 KB Output is correct
18 Correct 78 ms 2356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 916 KB Output is correct
2 Correct 94 ms 2508 KB Output is correct
3 Correct 93 ms 2384 KB Output is correct
4 Correct 81 ms 2380 KB Output is correct
5 Correct 71 ms 2324 KB Output is correct
6 Correct 69 ms 2316 KB Output is correct
7 Correct 66 ms 2508 KB Output is correct
8 Correct 78 ms 2404 KB Output is correct
9 Correct 92 ms 2468 KB Output is correct
10 Correct 82 ms 2392 KB Output is correct
11 Correct 75 ms 2424 KB Output is correct
12 Correct 78 ms 2436 KB Output is correct
13 Correct 88 ms 2400 KB Output is correct
14 Correct 76 ms 2488 KB Output is correct
15 Correct 70 ms 2428 KB Output is correct
16 Correct 78 ms 2508 KB Output is correct
17 Correct 76 ms 2480 KB Output is correct
18 Correct 78 ms 2356 KB Output is correct
19 Correct 450 ms 51864 KB Output is correct
20 Correct 348 ms 51768 KB Output is correct
21 Correct 272 ms 51396 KB Output is correct
22 Correct 346 ms 50508 KB Output is correct
23 Correct 135 ms 6188 KB Output is correct
24 Correct 132 ms 6084 KB Output is correct
25 Correct 295 ms 51924 KB Output is correct
26 Correct 318 ms 51852 KB Output is correct
27 Correct 392 ms 51940 KB Output is correct
28 Correct 369 ms 51812 KB Output is correct
29 Correct 334 ms 51612 KB Output is correct
30 Correct 148 ms 6092 KB Output is correct
31 Correct 325 ms 51996 KB Output is correct
32 Correct 345 ms 51128 KB Output is correct
33 Correct 144 ms 6124 KB Output is correct
34 Correct 325 ms 51916 KB Output is correct
35 Correct 253 ms 49740 KB Output is correct
36 Correct 125 ms 6168 KB Output is correct
37 Correct 149 ms 6160 KB Output is correct
38 Correct 376 ms 51632 KB Output is correct
39 Correct 157 ms 51904 KB Output is correct
40 Correct 251 ms 28840 KB Output is correct
41 Correct 489 ms 52120 KB Output is correct
42 Correct 81 ms 51384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 916 KB Output is correct
2 Correct 94 ms 2508 KB Output is correct
3 Correct 93 ms 2384 KB Output is correct
4 Correct 81 ms 2380 KB Output is correct
5 Correct 71 ms 2324 KB Output is correct
6 Correct 69 ms 2316 KB Output is correct
7 Correct 66 ms 2508 KB Output is correct
8 Correct 78 ms 2404 KB Output is correct
9 Correct 92 ms 2468 KB Output is correct
10 Correct 82 ms 2392 KB Output is correct
11 Correct 75 ms 2424 KB Output is correct
12 Correct 78 ms 2436 KB Output is correct
13 Correct 88 ms 2400 KB Output is correct
14 Correct 76 ms 2488 KB Output is correct
15 Correct 70 ms 2428 KB Output is correct
16 Correct 78 ms 2508 KB Output is correct
17 Correct 76 ms 2480 KB Output is correct
18 Correct 78 ms 2356 KB Output is correct
19 Correct 84 ms 2340 KB Output is correct
20 Correct 90 ms 2264 KB Output is correct
21 Incorrect 71 ms 2508 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 916 KB Output is correct
2 Correct 94 ms 2508 KB Output is correct
3 Correct 93 ms 2384 KB Output is correct
4 Correct 81 ms 2380 KB Output is correct
5 Correct 71 ms 2324 KB Output is correct
6 Correct 69 ms 2316 KB Output is correct
7 Correct 66 ms 2508 KB Output is correct
8 Correct 78 ms 2404 KB Output is correct
9 Correct 92 ms 2468 KB Output is correct
10 Correct 82 ms 2392 KB Output is correct
11 Correct 75 ms 2424 KB Output is correct
12 Correct 78 ms 2436 KB Output is correct
13 Correct 88 ms 2400 KB Output is correct
14 Correct 76 ms 2488 KB Output is correct
15 Correct 70 ms 2428 KB Output is correct
16 Correct 78 ms 2508 KB Output is correct
17 Correct 76 ms 2480 KB Output is correct
18 Correct 78 ms 2356 KB Output is correct
19 Correct 450 ms 51864 KB Output is correct
20 Correct 348 ms 51768 KB Output is correct
21 Correct 272 ms 51396 KB Output is correct
22 Correct 346 ms 50508 KB Output is correct
23 Correct 135 ms 6188 KB Output is correct
24 Correct 132 ms 6084 KB Output is correct
25 Correct 295 ms 51924 KB Output is correct
26 Correct 318 ms 51852 KB Output is correct
27 Correct 392 ms 51940 KB Output is correct
28 Correct 369 ms 51812 KB Output is correct
29 Correct 334 ms 51612 KB Output is correct
30 Correct 148 ms 6092 KB Output is correct
31 Correct 325 ms 51996 KB Output is correct
32 Correct 345 ms 51128 KB Output is correct
33 Correct 144 ms 6124 KB Output is correct
34 Correct 325 ms 51916 KB Output is correct
35 Correct 253 ms 49740 KB Output is correct
36 Correct 125 ms 6168 KB Output is correct
37 Correct 149 ms 6160 KB Output is correct
38 Correct 376 ms 51632 KB Output is correct
39 Correct 157 ms 51904 KB Output is correct
40 Correct 251 ms 28840 KB Output is correct
41 Correct 489 ms 52120 KB Output is correct
42 Correct 81 ms 51384 KB Output is correct
43 Correct 84 ms 2340 KB Output is correct
44 Correct 90 ms 2264 KB Output is correct
45 Incorrect 71 ms 2508 KB Output isn't correct
46 Halted 0 ms 0 KB -