Submission #788096

# Submission time Handle Problem Language Result Execution time Memory
788096 2023-07-19T18:22:17 Z anton Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 3792 KB
#include<bits/stdc++.h>

using namespace std;


const int MAX_N = 2*1e5;

int n, q, v[3][3], t[MAX_N][2];
bool is_set[3][3];
string s[3], r;

bool upd_val(int x, int y, int val){
    if(!is_set[x][y]){
        is_set[x][y] = true;
        v[x][y] = val;
    }
    else{
        if(v[x][y] != val){
            return false;
        }
    }
    return true;
}

signed main(){
    cin>>n;

    for(int i = 0; i<3; i++){
        cin>>s[i];
    }

    map<char, int> m;
    m['J'] = 0;
    m['O'] = 1;
    m['I'] = 2;

    for(int i = 0; i<n; i++){
        t[i][0] =(m[s[1][i]] -m[s[0][i]] +3)%3;
        t[i][1] =(m[s[2][i]] - m[s[0][i]] + 3)%3;

        //cout<<t[i][0]<<" "<<t[i][1]<<endl;
    }

    fill(&is_set[0][0], &is_set[0][0] + sizeof(is_set), false);

    cin>>q;
    cin>>r;

    bool ok = true;

    is_set[0][0] = true;
    v[0][0] =0;

    for(int i = -1; i<q; i++){

        if(i >=0){
            int l, ri;
            char c;
            cin>>l>>ri>>c;
            l--;
            ri--;

            for(int p = l; p<=ri; p++){
                r[p] = c;
            }
        }

        //cout<<r<<endl;
        ok = true;
        fill(&is_set[0][0], &is_set[0][0] + sizeof(is_set), false);
        for(int i = 0; i<n; i++){
            ok &= upd_val(t[i][0], t[i][1], (m[r[i]] - m[s[0][i]] + 3)%3);
        }

        for(int i = 0; i<9; i++){
            for(int b= 0; b<9; b++){
                for(int e = 0; e<9; e++){
                    if(is_set[b/3][b%3] && is_set[e/3][e%3]){
                        ok &= upd_val((e/3 + b/3)%3, (e+b)%3, (v[e/3][e%3] + v[b/3][b%3])%3);
                    }
                }
            }
        }

        if(ok){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }   
    }
}
# Verdict Execution time Memory Grader output
1 Correct 497 ms 2192 KB Output is correct
2 Correct 548 ms 2392 KB Output is correct
3 Correct 527 ms 2232 KB Output is correct
4 Correct 522 ms 2304 KB Output is correct
5 Correct 562 ms 2220 KB Output is correct
6 Correct 512 ms 2208 KB Output is correct
7 Correct 510 ms 2372 KB Output is correct
8 Correct 554 ms 2324 KB Output is correct
9 Correct 619 ms 2520 KB Output is correct
10 Correct 553 ms 2368 KB Output is correct
11 Correct 545 ms 2300 KB Output is correct
12 Correct 571 ms 2376 KB Output is correct
13 Correct 556 ms 2336 KB Output is correct
14 Correct 556 ms 2488 KB Output is correct
15 Correct 549 ms 2368 KB Output is correct
16 Correct 595 ms 2340 KB Output is correct
17 Correct 567 ms 2508 KB Output is correct
18 Correct 527 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 497 ms 2192 KB Output is correct
2 Correct 548 ms 2392 KB Output is correct
3 Correct 527 ms 2232 KB Output is correct
4 Correct 522 ms 2304 KB Output is correct
5 Correct 562 ms 2220 KB Output is correct
6 Correct 512 ms 2208 KB Output is correct
7 Correct 510 ms 2372 KB Output is correct
8 Correct 554 ms 2324 KB Output is correct
9 Correct 619 ms 2520 KB Output is correct
10 Correct 553 ms 2368 KB Output is correct
11 Correct 545 ms 2300 KB Output is correct
12 Correct 571 ms 2376 KB Output is correct
13 Correct 556 ms 2336 KB Output is correct
14 Correct 556 ms 2488 KB Output is correct
15 Correct 549 ms 2368 KB Output is correct
16 Correct 595 ms 2340 KB Output is correct
17 Correct 567 ms 2508 KB Output is correct
18 Correct 527 ms 2252 KB Output is correct
19 Execution timed out 7044 ms 3792 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 497 ms 2192 KB Output is correct
2 Correct 548 ms 2392 KB Output is correct
3 Correct 527 ms 2232 KB Output is correct
4 Correct 522 ms 2304 KB Output is correct
5 Correct 562 ms 2220 KB Output is correct
6 Correct 512 ms 2208 KB Output is correct
7 Correct 510 ms 2372 KB Output is correct
8 Correct 554 ms 2324 KB Output is correct
9 Correct 619 ms 2520 KB Output is correct
10 Correct 553 ms 2368 KB Output is correct
11 Correct 545 ms 2300 KB Output is correct
12 Correct 571 ms 2376 KB Output is correct
13 Correct 556 ms 2336 KB Output is correct
14 Correct 556 ms 2488 KB Output is correct
15 Correct 549 ms 2368 KB Output is correct
16 Correct 595 ms 2340 KB Output is correct
17 Correct 567 ms 2508 KB Output is correct
18 Correct 527 ms 2252 KB Output is correct
19 Correct 1034 ms 2236 KB Output is correct
20 Correct 1079 ms 2260 KB Output is correct
21 Correct 654 ms 2364 KB Output is correct
22 Correct 514 ms 2192 KB Output is correct
23 Correct 593 ms 2420 KB Output is correct
24 Correct 568 ms 2252 KB Output is correct
25 Correct 649 ms 2376 KB Output is correct
26 Correct 545 ms 2312 KB Output is correct
27 Correct 629 ms 2340 KB Output is correct
28 Correct 596 ms 2124 KB Output is correct
29 Correct 641 ms 2372 KB Output is correct
30 Correct 553 ms 2132 KB Output is correct
31 Correct 1135 ms 2420 KB Output is correct
32 Correct 1095 ms 2416 KB Output is correct
33 Correct 1101 ms 2408 KB Output is correct
34 Correct 994 ms 2424 KB Output is correct
35 Correct 1142 ms 2316 KB Output is correct
36 Correct 1111 ms 2340 KB Output is correct
37 Correct 1123 ms 2404 KB Output is correct
38 Correct 1130 ms 2436 KB Output is correct
39 Correct 1093 ms 2296 KB Output is correct
40 Correct 1152 ms 2500 KB Output is correct
41 Correct 1153 ms 2520 KB Output is correct
42 Correct 1093 ms 2420 KB Output is correct
43 Correct 1089 ms 2304 KB Output is correct
44 Correct 1100 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 497 ms 2192 KB Output is correct
2 Correct 548 ms 2392 KB Output is correct
3 Correct 527 ms 2232 KB Output is correct
4 Correct 522 ms 2304 KB Output is correct
5 Correct 562 ms 2220 KB Output is correct
6 Correct 512 ms 2208 KB Output is correct
7 Correct 510 ms 2372 KB Output is correct
8 Correct 554 ms 2324 KB Output is correct
9 Correct 619 ms 2520 KB Output is correct
10 Correct 553 ms 2368 KB Output is correct
11 Correct 545 ms 2300 KB Output is correct
12 Correct 571 ms 2376 KB Output is correct
13 Correct 556 ms 2336 KB Output is correct
14 Correct 556 ms 2488 KB Output is correct
15 Correct 549 ms 2368 KB Output is correct
16 Correct 595 ms 2340 KB Output is correct
17 Correct 567 ms 2508 KB Output is correct
18 Correct 527 ms 2252 KB Output is correct
19 Execution timed out 7044 ms 3792 KB Time limit exceeded
20 Halted 0 ms 0 KB -