Submission #423378

# Submission time Handle Problem Language Result Execution time Memory
423378 2021-06-11T04:31:34 Z 반딧불(#7610) Crossing (JOI21_crossing) C++17
26 / 100
282 ms 145368 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct segTree{
    int ans[400002][3], tree[400002], lazy[400002];

    void init(int i, int l, int r, int *A){
        tree[i] = 0, lazy[i] = -1;
        if(l==r){
            ans[i][A[l]] = 1;
            return;
        }
        int m = (l+r)>>1;
        init(i*2, l, m, A);
        init(i*2+1, m+1, r, A);
        for(int j=0; j<3; j++) ans[i][j] = ans[i*2][j] + ans[i*2+1][j];
    }

    void propagate(int i, int l, int r){
        if(lazy[i] == -1) return;
        tree[i] = ans[i][lazy[i]];
        if(l!=r) lazy[i*2] = lazy[i*2+1] = lazy[i];
        lazy[i] = -1;
    }

    void rangeUpdate(int i, int l, int r, int s, int e, int val){
        propagate(i, l, r);
        if(r<s || e<l) return;
        if(s<=l && r<=e){
            lazy[i] = val;
            propagate(i, l, r);
            return;
        }
        int m = (l+r)>>1;
        rangeUpdate(i*2, l, m, s, e, val);
        rangeUpdate(i*2+1, m+1, r, s, e, val);
        tree[i] = tree[i*2] + tree[i*2+1];
    }
} tree[9];

const char state[9][30] = {
    "000000000111111111222222222",
    "000111222000111222000111222",
    "012012012012012012012012012",
    "000222111222111000111000222",
    "021021021210210210102102102",
    "021210102021210102021210102",
    "021102210102210021210021102",
    "012201120120012201201120012",
    "012120201201012120120201012"
};

int n, q;
int s[3][200002];
int targ[200002];

void print(){
    for(int d=0; d<9; d++){
        if(tree[d].tree[1] == n){
            printf("Yes\n");
            return;
        }
    }
    printf("No\n");
}

int main(){
    scanf("%d", &n);
    for(int i=0; i<3; i++){
        for(int j=1; j<=n; j++){
            char c;
            scanf(" %c", &c);
            if(c == 'J') s[i][j] = 0;
            else if(c == 'O') s[i][j] = 1;
            else s[i][j] = 2;
        }
    }

    for(int d=0; d<9; d++){
        for(int i=1; i<=n; i++){
            int key = s[0][i] * 9 + s[1][i] * 3 + s[2][i];
            targ[i] = state[d][key] - '0';
        }
        tree[d].init(1, 1, n, targ);
    }

    scanf("%d", &q);
    for(int i=1; i<=n; i++){
        char c;
        scanf(" %c", &c);
        for(int d=0; d<9; d++){
            tree[d].rangeUpdate(1, 1, n, i, i, c=='J'?0:c=='O'?1:2);
        }
    }
    print();

    for(int i=1; i<=q; i++){
        int l, r; char c;
        scanf("%d %d %c", &l, &r, &c);
        for(int d=0; d<9; d++){
            tree[d].rangeUpdate(1, 1, n, l, r, c=='J'?0:c=='O'?1:2);
        }
        print();
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:71:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:75:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |             scanf(" %c", &c);
      |             ~~~~~^~~~~~~~~~~
Main.cpp:90:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:93:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         scanf(" %c", &c);
      |         ~~~~~^~~~~~~~~~~
Main.cpp:102:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |         scanf("%d %d %c", &l, &r, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 240 ms 1076 KB Output is correct
2 Correct 268 ms 1112 KB Output is correct
3 Correct 268 ms 1084 KB Output is correct
4 Correct 209 ms 1084 KB Output is correct
5 Correct 208 ms 1048 KB Output is correct
6 Correct 213 ms 1100 KB Output is correct
7 Correct 206 ms 1040 KB Output is correct
8 Correct 220 ms 1132 KB Output is correct
9 Correct 227 ms 1092 KB Output is correct
10 Correct 224 ms 1052 KB Output is correct
11 Correct 227 ms 1068 KB Output is correct
12 Correct 221 ms 1080 KB Output is correct
13 Correct 250 ms 1208 KB Output is correct
14 Correct 218 ms 1068 KB Output is correct
15 Correct 241 ms 1076 KB Output is correct
16 Correct 217 ms 1120 KB Output is correct
17 Correct 271 ms 1040 KB Output is correct
18 Correct 240 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 1076 KB Output is correct
2 Correct 268 ms 1112 KB Output is correct
3 Correct 268 ms 1084 KB Output is correct
4 Correct 209 ms 1084 KB Output is correct
5 Correct 208 ms 1048 KB Output is correct
6 Correct 213 ms 1100 KB Output is correct
7 Correct 206 ms 1040 KB Output is correct
8 Correct 220 ms 1132 KB Output is correct
9 Correct 227 ms 1092 KB Output is correct
10 Correct 224 ms 1052 KB Output is correct
11 Correct 227 ms 1068 KB Output is correct
12 Correct 221 ms 1080 KB Output is correct
13 Correct 250 ms 1208 KB Output is correct
14 Correct 218 ms 1068 KB Output is correct
15 Correct 241 ms 1076 KB Output is correct
16 Correct 217 ms 1120 KB Output is correct
17 Correct 271 ms 1040 KB Output is correct
18 Correct 240 ms 1088 KB Output is correct
19 Runtime error 175 ms 145368 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 240 ms 1076 KB Output is correct
2 Correct 268 ms 1112 KB Output is correct
3 Correct 268 ms 1084 KB Output is correct
4 Correct 209 ms 1084 KB Output is correct
5 Correct 208 ms 1048 KB Output is correct
6 Correct 213 ms 1100 KB Output is correct
7 Correct 206 ms 1040 KB Output is correct
8 Correct 220 ms 1132 KB Output is correct
9 Correct 227 ms 1092 KB Output is correct
10 Correct 224 ms 1052 KB Output is correct
11 Correct 227 ms 1068 KB Output is correct
12 Correct 221 ms 1080 KB Output is correct
13 Correct 250 ms 1208 KB Output is correct
14 Correct 218 ms 1068 KB Output is correct
15 Correct 241 ms 1076 KB Output is correct
16 Correct 217 ms 1120 KB Output is correct
17 Correct 271 ms 1040 KB Output is correct
18 Correct 240 ms 1088 KB Output is correct
19 Correct 282 ms 1068 KB Output is correct
20 Correct 263 ms 1148 KB Output is correct
21 Correct 252 ms 1100 KB Output is correct
22 Correct 187 ms 964 KB Output is correct
23 Correct 220 ms 1132 KB Output is correct
24 Correct 252 ms 1092 KB Output is correct
25 Correct 223 ms 1240 KB Output is correct
26 Correct 209 ms 1116 KB Output is correct
27 Correct 221 ms 1228 KB Output is correct
28 Correct 201 ms 1004 KB Output is correct
29 Correct 224 ms 1072 KB Output is correct
30 Correct 185 ms 1040 KB Output is correct
31 Correct 219 ms 1092 KB Output is correct
32 Correct 219 ms 1128 KB Output is correct
33 Correct 228 ms 1092 KB Output is correct
34 Correct 196 ms 1084 KB Output is correct
35 Correct 219 ms 1096 KB Output is correct
36 Correct 223 ms 1232 KB Output is correct
37 Correct 218 ms 1144 KB Output is correct
38 Correct 265 ms 1036 KB Output is correct
39 Correct 226 ms 1120 KB Output is correct
40 Correct 222 ms 1136 KB Output is correct
41 Correct 223 ms 1128 KB Output is correct
42 Correct 237 ms 1180 KB Output is correct
43 Correct 209 ms 1112 KB Output is correct
44 Correct 224 ms 1052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 1076 KB Output is correct
2 Correct 268 ms 1112 KB Output is correct
3 Correct 268 ms 1084 KB Output is correct
4 Correct 209 ms 1084 KB Output is correct
5 Correct 208 ms 1048 KB Output is correct
6 Correct 213 ms 1100 KB Output is correct
7 Correct 206 ms 1040 KB Output is correct
8 Correct 220 ms 1132 KB Output is correct
9 Correct 227 ms 1092 KB Output is correct
10 Correct 224 ms 1052 KB Output is correct
11 Correct 227 ms 1068 KB Output is correct
12 Correct 221 ms 1080 KB Output is correct
13 Correct 250 ms 1208 KB Output is correct
14 Correct 218 ms 1068 KB Output is correct
15 Correct 241 ms 1076 KB Output is correct
16 Correct 217 ms 1120 KB Output is correct
17 Correct 271 ms 1040 KB Output is correct
18 Correct 240 ms 1088 KB Output is correct
19 Runtime error 175 ms 145368 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -