Submission #1221759

#TimeUsernameProblemLanguageResultExecution timeMemory
1221759adam17Crossing (JOI21_crossing)C++20
0 / 100
0 ms320 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);
    mozne.resize(9);
    for (int i = 0; i < 9; i++) {
        mozne[i].resize(N);
        if (i < 3) {
            scanf("%s", &(nacteno[0]));
        }
        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);
    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;
            }
        }
        
        nacteno = (ok ? "Yes" : "No");
        printf("%s\n", &(nacteno[0]));

        if (q != Q) {
            int l, r;
            scanf("%i %i %s", &l, &r, &(nacteno[0])); l--;
            short x = preved(nacteno[0]);
            for (int j = l; j < r; j++) {
                T[j] = x;
            }
        }
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%i", &N);
      |     ~~~~~^~~~~~~~~~
Main.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf("%s", &(nacteno[0]));
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%i", &Q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%s", &(nacteno[0]));
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:65:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |             scanf("%i %i %s", &l, &r, &(nacteno[0])); l--;
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...