Submission #905997

# Submission time Handle Problem Language Result Execution time Memory
905997 2024-01-13T09:04:50 Z hmm789 Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 83816 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 998244353

struct node {
    int s, e, m, v, ans, lz;
    node *l, *r;
    node(int _s, int _e, vector<int> vec, vector<int> qry) {
        s = _s, e = _e, m = (s+e)/2, lz = -1;
        if(s != e) {
            l = new node(s, m, vec, qry);
            r = new node(m+1, e, vec, qry);
            if(l->v == -1 || r->v == -1 || l->v != r->v) v = -1;
            else v = l->v;
            ans = l->ans & r->ans;
        } else {
            v = vec[s];
            ans = vec[s] == qry[s];
        }
    }
    void prop() {
        if(lz == -1) return;
        ans = lz == v;
        if(s != e) {
            l->lz = lz;
            r->lz = lz;
        }
        lz = -1;
    }
    void update(int x, int y, int val) {
        prop();
        if(x <= s && e <= y) {lz = val; return;}
        else if(x > m) r->update(x, y, val);
        else if(y <= m) l->update(x, y, val);
        else l->update(x, y, val), r->update(x, y, val);
        l->prop(); r->prop();
        ans = l->ans & r->ans;
    }
    int query() {
        prop();
        return ans;
    }
} *root[27];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q, l, r, x;
    cin >> n;
    int a[3][n];
    string s;
    for(int j = 0; j < 3; j++) {
        cin >> s;
        for(int i = 0; i < n; i++) {
            if(s[i] == 'J') a[j][i] = 0;
            else if(s[i] == 'O') a[j][i] = 1;
            else a[j][i] = 2;
        }
    }
    vector<vector<int>> valid;
    for(int x = 0; x < 3; x++) {
        for(int y = 0; y < 3; y++) {
            for(int z = 0; z < 3; z++) {
                if((x+y+z)%3 != 1) continue;
                vector<int> v;
                for(int i = 0; i < n; i++) {
                    v.push_back((a[0][i]*x+a[1][i]*y+a[2][i]*z)%3);
                }
                valid.push_back(v);
            }
        }
    }
    cin >> q >> s;
    vector<int> vs;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'J') vs.push_back(0);
        else if(s[i] == 'O') vs.push_back(1);
        else vs.push_back(2);
    }
    int ans = 0;
    for(int i = 0; i < valid.size(); i++) {
        root[i] = new node(0, n-1, valid[i], vs);
        if(root[i]->query()) ans = 1;
    }
    cout << (ans?"Yes":"No") << '\n';
    char c;
    while(q--) {
        cin >> l >> r >> c;
        l--; r--;
        if(c == 'J') x = 0;
        else if(c == 'O') x = 1;
        else x = 2;
        ans = 0;
        for(int i = 0; i < valid.size(); i++) {
            root[i]->update(l, r, x);
            if(root[i]->query()) ans = 1;
        }
        cout << (ans?"Yes":"No") << '\n';
    }
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:83:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i = 0; i < valid.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
Main.cpp:96:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |         for(int i = 0; i < valid.size(); i++) {
      |                        ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 164 ms 2388 KB Output is correct
2 Correct 182 ms 2568 KB Output is correct
3 Correct 196 ms 2528 KB Output is correct
4 Correct 143 ms 2716 KB Output is correct
5 Correct 136 ms 2388 KB Output is correct
6 Correct 138 ms 2456 KB Output is correct
7 Correct 140 ms 2644 KB Output is correct
8 Correct 145 ms 2644 KB Output is correct
9 Correct 145 ms 2644 KB Output is correct
10 Correct 154 ms 2900 KB Output is correct
11 Correct 152 ms 2648 KB Output is correct
12 Correct 148 ms 2528 KB Output is correct
13 Correct 148 ms 2720 KB Output is correct
14 Correct 145 ms 2516 KB Output is correct
15 Correct 159 ms 2680 KB Output is correct
16 Correct 144 ms 2900 KB Output is correct
17 Correct 150 ms 2492 KB Output is correct
18 Correct 166 ms 2572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 2388 KB Output is correct
2 Correct 182 ms 2568 KB Output is correct
3 Correct 196 ms 2528 KB Output is correct
4 Correct 143 ms 2716 KB Output is correct
5 Correct 136 ms 2388 KB Output is correct
6 Correct 138 ms 2456 KB Output is correct
7 Correct 140 ms 2644 KB Output is correct
8 Correct 145 ms 2644 KB Output is correct
9 Correct 145 ms 2644 KB Output is correct
10 Correct 154 ms 2900 KB Output is correct
11 Correct 152 ms 2648 KB Output is correct
12 Correct 148 ms 2528 KB Output is correct
13 Correct 148 ms 2720 KB Output is correct
14 Correct 145 ms 2516 KB Output is correct
15 Correct 159 ms 2680 KB Output is correct
16 Correct 144 ms 2900 KB Output is correct
17 Correct 150 ms 2492 KB Output is correct
18 Correct 166 ms 2572 KB Output is correct
19 Execution timed out 7090 ms 83816 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 164 ms 2388 KB Output is correct
2 Correct 182 ms 2568 KB Output is correct
3 Correct 196 ms 2528 KB Output is correct
4 Correct 143 ms 2716 KB Output is correct
5 Correct 136 ms 2388 KB Output is correct
6 Correct 138 ms 2456 KB Output is correct
7 Correct 140 ms 2644 KB Output is correct
8 Correct 145 ms 2644 KB Output is correct
9 Correct 145 ms 2644 KB Output is correct
10 Correct 154 ms 2900 KB Output is correct
11 Correct 152 ms 2648 KB Output is correct
12 Correct 148 ms 2528 KB Output is correct
13 Correct 148 ms 2720 KB Output is correct
14 Correct 145 ms 2516 KB Output is correct
15 Correct 159 ms 2680 KB Output is correct
16 Correct 144 ms 2900 KB Output is correct
17 Correct 150 ms 2492 KB Output is correct
18 Correct 166 ms 2572 KB Output is correct
19 Correct 168 ms 2644 KB Output is correct
20 Correct 194 ms 2460 KB Output is correct
21 Correct 150 ms 2956 KB Output is correct
22 Correct 123 ms 2420 KB Output is correct
23 Correct 142 ms 2580 KB Output is correct
24 Correct 141 ms 2860 KB Output is correct
25 Correct 149 ms 2588 KB Output is correct
26 Correct 134 ms 2388 KB Output is correct
27 Correct 149 ms 2536 KB Output is correct
28 Correct 133 ms 2388 KB Output is correct
29 Correct 158 ms 2668 KB Output is correct
30 Correct 140 ms 2388 KB Output is correct
31 Correct 144 ms 2744 KB Output is correct
32 Correct 144 ms 2548 KB Output is correct
33 Correct 149 ms 2888 KB Output is correct
34 Correct 127 ms 2384 KB Output is correct
35 Correct 147 ms 2528 KB Output is correct
36 Correct 169 ms 2720 KB Output is correct
37 Correct 144 ms 2520 KB Output is correct
38 Correct 148 ms 2736 KB Output is correct
39 Correct 163 ms 2644 KB Output is correct
40 Correct 148 ms 2612 KB Output is correct
41 Correct 153 ms 2504 KB Output is correct
42 Correct 169 ms 2644 KB Output is correct
43 Correct 141 ms 2644 KB Output is correct
44 Correct 148 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 2388 KB Output is correct
2 Correct 182 ms 2568 KB Output is correct
3 Correct 196 ms 2528 KB Output is correct
4 Correct 143 ms 2716 KB Output is correct
5 Correct 136 ms 2388 KB Output is correct
6 Correct 138 ms 2456 KB Output is correct
7 Correct 140 ms 2644 KB Output is correct
8 Correct 145 ms 2644 KB Output is correct
9 Correct 145 ms 2644 KB Output is correct
10 Correct 154 ms 2900 KB Output is correct
11 Correct 152 ms 2648 KB Output is correct
12 Correct 148 ms 2528 KB Output is correct
13 Correct 148 ms 2720 KB Output is correct
14 Correct 145 ms 2516 KB Output is correct
15 Correct 159 ms 2680 KB Output is correct
16 Correct 144 ms 2900 KB Output is correct
17 Correct 150 ms 2492 KB Output is correct
18 Correct 166 ms 2572 KB Output is correct
19 Execution timed out 7090 ms 83816 KB Time limit exceeded
20 Halted 0 ms 0 KB -