# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1221751 | adam17 | Crossing (JOI21_crossing) | C++20 | 0 ms | 320 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--;
char x = preved(nacteno[0]);
for (int j = l; j < r; j++) {
T[j] = x;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |