Submission #1221867

#TimeUsernameProblemLanguageResultExecution timeMemory
1221867adam17Crossing (JOI21_crossing)C++20
26 / 100
7092 ms4692 KiB
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int N, Q;
vector<vector<short>> mozne;
vector<short> T;
string nacteno;


short preved(char x) {
    return ((x == 'O') ? 0 : ((x == 'I') ? 1 : 2));
}


int main() {
    // scanf("%i", &N);
    cin >> N;
    mozne.resize(9);
    for (int i = 0; i < 9; i++) {
        mozne[i].resize(N);
        if (i < 3) {
            // scanf("%s", &(nacteno[0]));
            cin >> nacteno;
        }
        for (int j = 0; j < N; j++) {
            if (i < 3) {
                mozne[i][j] = preved(nacteno[j]);
            } else if (i < 6) {
                mozne[i][j] = (12 - mozne[(i + 1) % 3][j] - mozne[(i + 2) % 3][j]) % 3;
            } else {
                mozne[i][j] = (3 + mozne[(i + 1) % 3][j] + mozne[(i + 2) % 3][j] - mozne[i % 3][j]) % 3;
            }
            // cout << "OIJ"[mozne[i][j]];
        }
        // cout << endl;
    }

    // scanf("%i", &Q);
    cin >> Q >> nacteno;
    // scanf("%s", &(nacteno[0]));
    T.resize(N);
    for (int i = 0; i < N; i++) {
        T[i] = preved(nacteno[i]);
    }


    for (int q = 0; q <= Q; q++) {
        bool ok = false;
        for (int i = 0; i < 9; i++) {
            bool ok_zde = true;
            for (int j = 0; j < N; j++) {
                if (mozne[i][j] != T[j]) {
                    ok_zde = false;
                }
            }
            if (ok_zde) {
                ok = true;
            }
        }
        

        cout << (ok ? "Yes" : "No") << endl;
        // nacteno = (ok ? "Yes" : "No");
        // printf("%s\n", &(nacteno[0]));


        if (q != Q) {
            int l, r; char xx;
            // scanf("%i %i %s", &l, &r, &(nacteno[0])); l--;
            cin >> l >> r >> xx; l--;
            short x = preved(xx);
            for (int j = l; j < r; j++) {
                T[j] = x;
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...