#include <iostream>
using namespace std;
string s1,s2,s3,s4,s5,s6,s7,s8,s9;
int main(){
int n; cin >> n;
cin >> s1 >> s2 >> s3;
for (int i = 0; i < n; ++i){
if (s1[i] == s2[i]){
s4 += s1[i];
} else{
if ((s1[i] == 'J' && s2[i] == 'O')||(s1[i] == 'O' && s2[i] == 'J')){
s4 += 'I';
}
if ((s1[i] == 'J' && s2[i] == 'I')||(s1[i] == 'I' && s2[i] == 'J')){
s4 += 'O';
}
if ((s1[i] == 'I' && s2[i] == 'O')||(s1[i] == 'O' && s2[i] == 'I')){
s4 += 'J';
}
}
}
for (int i = 0; i < n; ++i){
if (s1[i] == s3[i]){
s5 += s1[i];
} else{
if ((s1[i] == 'J' && s3[i] == 'O')||(s1[i] == 'O' && s3[i] == 'J')){
s5 += 'I';
}
if ((s1[i] == 'J' && s3[i] == 'I')||(s1[i] == 'I' && s3[i] == 'J')){
s5 += 'O';
}
if ((s1[i] == 'I' && s3[i] == 'O')||(s1[i] == 'O' && s3[i] == 'I')){
s5 += 'J';
}
}
}
for (int i = 0; i < n; ++i){
if (s3[i] == s2[i]){
s6 += s3[i];
} else{
if ((s3[i] == 'J' && s2[i] == 'O')||(s3[i] == 'O' && s2[i] == 'J')){
s6 += 'I';
}
if ((s3[i] == 'J' && s2[i] == 'I')||(s3[i] == 'I' && s2[i] == 'J')){
s6 += 'O';
}
if ((s3[i] == 'I' && s2[i] == 'O')||(s3[i] == 'O' && s2[i] == 'I')){
s6 += 'J';
}
}
}
for (int i = 0; i < n; ++i){
if (s1[i] == s6[i]){
s7 += s1[i];
} else{
if ((s1[i] == 'J' && s6[i] == 'O')||(s1[i] == 'O' && s6[i] == 'J')){
s7 += 'I';
}
if ((s1[i] == 'J' && s6[i] == 'I')||(s1[i] == 'I' && s6[i] == 'J')){
s7 += 'O';
}
if ((s1[i] == 'I' && s6[i] == 'O')||(s1[i] == 'O' && s6[i] == 'I')){
s7 += 'J';
}
}
}
for (int i = 0; i < n; ++i){
if (s5[i] == s2[i]){
s8 += s5[i];
} else{
if ((s5[i] == 'J' && s2[i] == 'O')||(s5[i] == 'O' && s2[i] == 'J')){
s8 += 'I';
}
if ((s5[i] == 'J' && s2[i] == 'I')||(s5[i] == 'I' && s2[i] == 'J')){
s8 += 'O';
}
if ((s5[i] == 'I' && s2[i] == 'O')||(s5[i] == 'O' && s2[i] == 'I')){
s8 += 'J';
}
}
}
for (int i = 0; i < n; ++i){
if (s3[i] == s4[i]){
s9 += s3[i];
} else{
if ((s3[i] == 'J' && s4[i] == 'O')||(s3[i] == 'O' && s4[i] == 'J')){
s9 += 'I';
}
if ((s3[i] == 'J' && s4[i] == 'I')||(s3[i] == 'I' && s4[i] == 'J')){
s9 += 'O';
}
if ((s3[i] == 'I' && s4[i] == 'O')||(s3[i] == 'O' && s4[i] == 'I')){
s9 += 'J';
}
}
}
int q; cin >> q;
string ej; cin >> ej;
if (ej == s1 || ej == s2 || ej == s3|| ej == s4|| ej == s5|| ej == s6|| ej == s7|| ej == s8|| ej == s9){
cout << "Yes" << endl;
} else{
cout << "No" << endl;
}
for (int i = 0; i < q; ++i){
int l, r; cin >> l >> r;
char c; cin >> c;
for (int i = l-1; i < r; ++i){
ej[i] = c;
}
if (ej == s1 || ej == s2 || ej == s3|| ej == s4|| ej == s5|| ej == s6|| ej == s7|| ej == s8|| ej == s9){
cout << "Yes" << endl;
} else{
cout << "No" << endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
720 KB |
Output is correct |
2 |
Correct |
490 ms |
832 KB |
Output is correct |
3 |
Correct |
420 ms |
824 KB |
Output is correct |
4 |
Correct |
374 ms |
836 KB |
Output is correct |
5 |
Correct |
469 ms |
1140 KB |
Output is correct |
6 |
Correct |
541 ms |
992 KB |
Output is correct |
7 |
Correct |
392 ms |
1088 KB |
Output is correct |
8 |
Correct |
505 ms |
1132 KB |
Output is correct |
9 |
Correct |
411 ms |
1124 KB |
Output is correct |
10 |
Correct |
437 ms |
1132 KB |
Output is correct |
11 |
Correct |
411 ms |
1140 KB |
Output is correct |
12 |
Correct |
377 ms |
1160 KB |
Output is correct |
13 |
Correct |
421 ms |
1120 KB |
Output is correct |
14 |
Correct |
383 ms |
1196 KB |
Output is correct |
15 |
Correct |
355 ms |
1068 KB |
Output is correct |
16 |
Correct |
402 ms |
1152 KB |
Output is correct |
17 |
Correct |
383 ms |
1056 KB |
Output is correct |
18 |
Correct |
438 ms |
1148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
720 KB |
Output is correct |
2 |
Correct |
490 ms |
832 KB |
Output is correct |
3 |
Correct |
420 ms |
824 KB |
Output is correct |
4 |
Correct |
374 ms |
836 KB |
Output is correct |
5 |
Correct |
469 ms |
1140 KB |
Output is correct |
6 |
Correct |
541 ms |
992 KB |
Output is correct |
7 |
Correct |
392 ms |
1088 KB |
Output is correct |
8 |
Correct |
505 ms |
1132 KB |
Output is correct |
9 |
Correct |
411 ms |
1124 KB |
Output is correct |
10 |
Correct |
437 ms |
1132 KB |
Output is correct |
11 |
Correct |
411 ms |
1140 KB |
Output is correct |
12 |
Correct |
377 ms |
1160 KB |
Output is correct |
13 |
Correct |
421 ms |
1120 KB |
Output is correct |
14 |
Correct |
383 ms |
1196 KB |
Output is correct |
15 |
Correct |
355 ms |
1068 KB |
Output is correct |
16 |
Correct |
402 ms |
1152 KB |
Output is correct |
17 |
Correct |
383 ms |
1056 KB |
Output is correct |
18 |
Correct |
438 ms |
1148 KB |
Output is correct |
19 |
Execution timed out |
7006 ms |
2820 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
720 KB |
Output is correct |
2 |
Correct |
490 ms |
832 KB |
Output is correct |
3 |
Correct |
420 ms |
824 KB |
Output is correct |
4 |
Correct |
374 ms |
836 KB |
Output is correct |
5 |
Correct |
469 ms |
1140 KB |
Output is correct |
6 |
Correct |
541 ms |
992 KB |
Output is correct |
7 |
Correct |
392 ms |
1088 KB |
Output is correct |
8 |
Correct |
505 ms |
1132 KB |
Output is correct |
9 |
Correct |
411 ms |
1124 KB |
Output is correct |
10 |
Correct |
437 ms |
1132 KB |
Output is correct |
11 |
Correct |
411 ms |
1140 KB |
Output is correct |
12 |
Correct |
377 ms |
1160 KB |
Output is correct |
13 |
Correct |
421 ms |
1120 KB |
Output is correct |
14 |
Correct |
383 ms |
1196 KB |
Output is correct |
15 |
Correct |
355 ms |
1068 KB |
Output is correct |
16 |
Correct |
402 ms |
1152 KB |
Output is correct |
17 |
Correct |
383 ms |
1056 KB |
Output is correct |
18 |
Correct |
438 ms |
1148 KB |
Output is correct |
19 |
Correct |
378 ms |
848 KB |
Output is correct |
20 |
Correct |
424 ms |
880 KB |
Output is correct |
21 |
Correct |
377 ms |
880 KB |
Output is correct |
22 |
Correct |
336 ms |
2356 KB |
Output is correct |
23 |
Correct |
359 ms |
2344 KB |
Output is correct |
24 |
Correct |
366 ms |
2276 KB |
Output is correct |
25 |
Correct |
347 ms |
2480 KB |
Output is correct |
26 |
Correct |
330 ms |
2248 KB |
Output is correct |
27 |
Correct |
347 ms |
2380 KB |
Output is correct |
28 |
Correct |
309 ms |
2172 KB |
Output is correct |
29 |
Correct |
353 ms |
2352 KB |
Output is correct |
30 |
Correct |
323 ms |
2216 KB |
Output is correct |
31 |
Correct |
342 ms |
2404 KB |
Output is correct |
32 |
Correct |
340 ms |
2304 KB |
Output is correct |
33 |
Correct |
333 ms |
2344 KB |
Output is correct |
34 |
Correct |
325 ms |
2212 KB |
Output is correct |
35 |
Correct |
342 ms |
2416 KB |
Output is correct |
36 |
Correct |
386 ms |
2304 KB |
Output is correct |
37 |
Correct |
364 ms |
2324 KB |
Output is correct |
38 |
Correct |
366 ms |
2320 KB |
Output is correct |
39 |
Correct |
358 ms |
2380 KB |
Output is correct |
40 |
Correct |
356 ms |
2368 KB |
Output is correct |
41 |
Correct |
368 ms |
2416 KB |
Output is correct |
42 |
Correct |
392 ms |
2320 KB |
Output is correct |
43 |
Correct |
394 ms |
2248 KB |
Output is correct |
44 |
Correct |
392 ms |
2412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
720 KB |
Output is correct |
2 |
Correct |
490 ms |
832 KB |
Output is correct |
3 |
Correct |
420 ms |
824 KB |
Output is correct |
4 |
Correct |
374 ms |
836 KB |
Output is correct |
5 |
Correct |
469 ms |
1140 KB |
Output is correct |
6 |
Correct |
541 ms |
992 KB |
Output is correct |
7 |
Correct |
392 ms |
1088 KB |
Output is correct |
8 |
Correct |
505 ms |
1132 KB |
Output is correct |
9 |
Correct |
411 ms |
1124 KB |
Output is correct |
10 |
Correct |
437 ms |
1132 KB |
Output is correct |
11 |
Correct |
411 ms |
1140 KB |
Output is correct |
12 |
Correct |
377 ms |
1160 KB |
Output is correct |
13 |
Correct |
421 ms |
1120 KB |
Output is correct |
14 |
Correct |
383 ms |
1196 KB |
Output is correct |
15 |
Correct |
355 ms |
1068 KB |
Output is correct |
16 |
Correct |
402 ms |
1152 KB |
Output is correct |
17 |
Correct |
383 ms |
1056 KB |
Output is correct |
18 |
Correct |
438 ms |
1148 KB |
Output is correct |
19 |
Execution timed out |
7006 ms |
2820 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |