Submission #423384

# Submission time Handle Problem Language Result Execution time Memory
423384 2021-06-11T04:47:02 Z benedict0724 Crossing (JOI21_crossing) C++17
26 / 100
333 ms 12172 KB
#include <iostream>

using namespace std;

int tree[800002], a[800002], b[800002], c[800002], lazy[800002];
int n, q;
string s1, s2, s3, t;

void propagate(int i, int l, int r)
{
    if(lazy[i] == 0) return;
    if(lazy[i] == 1 && b[i] == 0 && c[i] == 0) tree[i] = 1;
    else if(lazy[i] == 2 && a[i] == 0 && c[i] == 0) tree[i] = 1;
    else if(lazy[i] == 3 && a[i] == 0 && b[i] == 0) tree[i] = 1;
    else tree[i] = 0;

    if(l != r)
    {
        lazy[i*2] = lazy[i];
        lazy[i*2+1] = lazy[i];
    }
    lazy[i] = 0;
}

void init(int i, int l, int r)
{
    if(l == r)
    {
        if(s1[l] == 'J') a[i] = 1;
        if(s1[l] == 'O') b[i] = 1;
        if(s1[l] == 'I') c[i] = 1;
        if(s1[l] == t[l]) tree[i] = 1;
        return;
    }
    int m = (l + r)/2;
    init(i*2, l, m);
    init(i*2+1, m+1, r);
    a[i] = a[i*2] | a[i*2+1];
    b[i] = b[i*2] | b[i*2+1];
    c[i] = c[i*2] | c[i*2+1];
    tree[i] = tree[i*2] & tree[i*2+1];
}

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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    cin >> s1 >> s2 >> s3;
    cin >> q;
    cin >> t;
    init(1, 0, n-1);
    cout << (tree[1] ? "Yes\n" : "No\n");
    for(int i=1;i<=q;i++)
    {
        int l, r, ch; char c;
        cin >> l >> r >> c;
        if(c == 'J') ch = 1;
        if(c == 'O') ch = 2;
        if(c == 'I') ch = 3;
        update(1, 0, n-1, l-1, r-1, ch);
        cout << (tree[1] ? "Yes\n" : "No\n");
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:76:15: warning: 'ch' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |         update(1, 0, n-1, l-1, r-1, ch);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 91 ms 836 KB Output is correct
2 Correct 108 ms 972 KB Output is correct
3 Correct 119 ms 908 KB Output is correct
4 Correct 84 ms 920 KB Output is correct
5 Correct 82 ms 900 KB Output is correct
6 Correct 84 ms 804 KB Output is correct
7 Correct 88 ms 960 KB Output is correct
8 Correct 95 ms 880 KB Output is correct
9 Correct 95 ms 1056 KB Output is correct
10 Correct 90 ms 832 KB Output is correct
11 Correct 91 ms 864 KB Output is correct
12 Correct 88 ms 836 KB Output is correct
13 Correct 95 ms 836 KB Output is correct
14 Correct 88 ms 916 KB Output is correct
15 Correct 91 ms 908 KB Output is correct
16 Correct 89 ms 964 KB Output is correct
17 Correct 90 ms 832 KB Output is correct
18 Correct 86 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 836 KB Output is correct
2 Correct 108 ms 972 KB Output is correct
3 Correct 119 ms 908 KB Output is correct
4 Correct 84 ms 920 KB Output is correct
5 Correct 82 ms 900 KB Output is correct
6 Correct 84 ms 804 KB Output is correct
7 Correct 88 ms 960 KB Output is correct
8 Correct 95 ms 880 KB Output is correct
9 Correct 95 ms 1056 KB Output is correct
10 Correct 90 ms 832 KB Output is correct
11 Correct 91 ms 864 KB Output is correct
12 Correct 88 ms 836 KB Output is correct
13 Correct 95 ms 836 KB Output is correct
14 Correct 88 ms 916 KB Output is correct
15 Correct 91 ms 908 KB Output is correct
16 Correct 89 ms 964 KB Output is correct
17 Correct 90 ms 832 KB Output is correct
18 Correct 86 ms 956 KB Output is correct
19 Correct 311 ms 12072 KB Output is correct
20 Correct 286 ms 10456 KB Output is correct
21 Correct 226 ms 11960 KB Output is correct
22 Correct 245 ms 11932 KB Output is correct
23 Correct 141 ms 1584 KB Output is correct
24 Correct 136 ms 1712 KB Output is correct
25 Correct 222 ms 12032 KB Output is correct
26 Correct 254 ms 12016 KB Output is correct
27 Correct 257 ms 12020 KB Output is correct
28 Correct 259 ms 12104 KB Output is correct
29 Correct 255 ms 12172 KB Output is correct
30 Correct 154 ms 1568 KB Output is correct
31 Correct 258 ms 12100 KB Output is correct
32 Correct 252 ms 11932 KB Output is correct
33 Correct 142 ms 1596 KB Output is correct
34 Correct 274 ms 12080 KB Output is correct
35 Correct 196 ms 11780 KB Output is correct
36 Correct 146 ms 1548 KB Output is correct
37 Correct 142 ms 1596 KB Output is correct
38 Correct 244 ms 8412 KB Output is correct
39 Correct 142 ms 10084 KB Output is correct
40 Correct 174 ms 6264 KB Output is correct
41 Correct 333 ms 10252 KB Output is correct
42 Correct 55 ms 8212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 836 KB Output is correct
2 Correct 108 ms 972 KB Output is correct
3 Correct 119 ms 908 KB Output is correct
4 Correct 84 ms 920 KB Output is correct
5 Correct 82 ms 900 KB Output is correct
6 Correct 84 ms 804 KB Output is correct
7 Correct 88 ms 960 KB Output is correct
8 Correct 95 ms 880 KB Output is correct
9 Correct 95 ms 1056 KB Output is correct
10 Correct 90 ms 832 KB Output is correct
11 Correct 91 ms 864 KB Output is correct
12 Correct 88 ms 836 KB Output is correct
13 Correct 95 ms 836 KB Output is correct
14 Correct 88 ms 916 KB Output is correct
15 Correct 91 ms 908 KB Output is correct
16 Correct 89 ms 964 KB Output is correct
17 Correct 90 ms 832 KB Output is correct
18 Correct 86 ms 956 KB Output is correct
19 Correct 98 ms 888 KB Output is correct
20 Correct 99 ms 924 KB Output is correct
21 Incorrect 88 ms 836 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 836 KB Output is correct
2 Correct 108 ms 972 KB Output is correct
3 Correct 119 ms 908 KB Output is correct
4 Correct 84 ms 920 KB Output is correct
5 Correct 82 ms 900 KB Output is correct
6 Correct 84 ms 804 KB Output is correct
7 Correct 88 ms 960 KB Output is correct
8 Correct 95 ms 880 KB Output is correct
9 Correct 95 ms 1056 KB Output is correct
10 Correct 90 ms 832 KB Output is correct
11 Correct 91 ms 864 KB Output is correct
12 Correct 88 ms 836 KB Output is correct
13 Correct 95 ms 836 KB Output is correct
14 Correct 88 ms 916 KB Output is correct
15 Correct 91 ms 908 KB Output is correct
16 Correct 89 ms 964 KB Output is correct
17 Correct 90 ms 832 KB Output is correct
18 Correct 86 ms 956 KB Output is correct
19 Correct 311 ms 12072 KB Output is correct
20 Correct 286 ms 10456 KB Output is correct
21 Correct 226 ms 11960 KB Output is correct
22 Correct 245 ms 11932 KB Output is correct
23 Correct 141 ms 1584 KB Output is correct
24 Correct 136 ms 1712 KB Output is correct
25 Correct 222 ms 12032 KB Output is correct
26 Correct 254 ms 12016 KB Output is correct
27 Correct 257 ms 12020 KB Output is correct
28 Correct 259 ms 12104 KB Output is correct
29 Correct 255 ms 12172 KB Output is correct
30 Correct 154 ms 1568 KB Output is correct
31 Correct 258 ms 12100 KB Output is correct
32 Correct 252 ms 11932 KB Output is correct
33 Correct 142 ms 1596 KB Output is correct
34 Correct 274 ms 12080 KB Output is correct
35 Correct 196 ms 11780 KB Output is correct
36 Correct 146 ms 1548 KB Output is correct
37 Correct 142 ms 1596 KB Output is correct
38 Correct 244 ms 8412 KB Output is correct
39 Correct 142 ms 10084 KB Output is correct
40 Correct 174 ms 6264 KB Output is correct
41 Correct 333 ms 10252 KB Output is correct
42 Correct 55 ms 8212 KB Output is correct
43 Correct 98 ms 888 KB Output is correct
44 Correct 99 ms 924 KB Output is correct
45 Incorrect 88 ms 836 KB Output isn't correct
46 Halted 0 ms 0 KB -