#include <bits/stdc++.h>
using namespace std;
char cross(char a, char b) {
if (a == b) return a;
if (a != 'O' && b != 'O') return 'O';
if (a != 'J' && b != 'J') return 'J';
return 'I';
}
string merge(string a, string b) {
string c(a.size(), ' ');
for (int i = 0; i<a.size(); ++i) {
c[i] = cross(a[i], b[i]);
}
return c;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n,q; cin >> n;
vector<string> start(3);
set<string> s;
for (string &S :start) {
cin >> S;
s.insert(S);
}
for (int i = 0; i<3; ++i) for (int j = i+1; j<3; ++j) s.insert(merge(start[i], start[j]));
s.insert(merge(start[0], merge(start[2], start[1])));
s.insert(merge(start[1], merge(start[2], start[0])));
s.insert(merge(start[2], merge(start[1], start[0])));
cin >> q;
string seq; cin >> seq;
cout << (s.count(seq) ? "Yes" : "No") << '\n';
while (q--) {
int l,r; char c;
cin >> l >> r >> c;
for (int i = l-1; i<r; ++i) seq[i] = c;
cout << (s.count(seq) ? "Yes" : "No") << '\n';
}
}
Compilation message
Main.cpp: In function 'std::string merge(std::string, std::string)':
Main.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for (int i = 0; i<a.size(); ++i) {
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
852 KB |
Output is correct |
2 |
Correct |
24 ms |
856 KB |
Output is correct |
3 |
Correct |
43 ms |
852 KB |
Output is correct |
4 |
Correct |
23 ms |
856 KB |
Output is correct |
5 |
Correct |
24 ms |
860 KB |
Output is correct |
6 |
Correct |
39 ms |
856 KB |
Output is correct |
7 |
Correct |
23 ms |
864 KB |
Output is correct |
8 |
Correct |
25 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
860 KB |
Output is correct |
10 |
Correct |
26 ms |
856 KB |
Output is correct |
11 |
Correct |
23 ms |
860 KB |
Output is correct |
12 |
Correct |
24 ms |
856 KB |
Output is correct |
13 |
Correct |
24 ms |
856 KB |
Output is correct |
14 |
Correct |
24 ms |
836 KB |
Output is correct |
15 |
Correct |
42 ms |
824 KB |
Output is correct |
16 |
Correct |
33 ms |
848 KB |
Output is correct |
17 |
Correct |
42 ms |
816 KB |
Output is correct |
18 |
Correct |
34 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
852 KB |
Output is correct |
2 |
Correct |
24 ms |
856 KB |
Output is correct |
3 |
Correct |
43 ms |
852 KB |
Output is correct |
4 |
Correct |
23 ms |
856 KB |
Output is correct |
5 |
Correct |
24 ms |
860 KB |
Output is correct |
6 |
Correct |
39 ms |
856 KB |
Output is correct |
7 |
Correct |
23 ms |
864 KB |
Output is correct |
8 |
Correct |
25 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
860 KB |
Output is correct |
10 |
Correct |
26 ms |
856 KB |
Output is correct |
11 |
Correct |
23 ms |
860 KB |
Output is correct |
12 |
Correct |
24 ms |
856 KB |
Output is correct |
13 |
Correct |
24 ms |
856 KB |
Output is correct |
14 |
Correct |
24 ms |
836 KB |
Output is correct |
15 |
Correct |
42 ms |
824 KB |
Output is correct |
16 |
Correct |
33 ms |
848 KB |
Output is correct |
17 |
Correct |
42 ms |
816 KB |
Output is correct |
18 |
Correct |
34 ms |
860 KB |
Output is correct |
19 |
Correct |
3648 ms |
2284 KB |
Output is correct |
20 |
Execution timed out |
7071 ms |
2216 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
852 KB |
Output is correct |
2 |
Correct |
24 ms |
856 KB |
Output is correct |
3 |
Correct |
43 ms |
852 KB |
Output is correct |
4 |
Correct |
23 ms |
856 KB |
Output is correct |
5 |
Correct |
24 ms |
860 KB |
Output is correct |
6 |
Correct |
39 ms |
856 KB |
Output is correct |
7 |
Correct |
23 ms |
864 KB |
Output is correct |
8 |
Correct |
25 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
860 KB |
Output is correct |
10 |
Correct |
26 ms |
856 KB |
Output is correct |
11 |
Correct |
23 ms |
860 KB |
Output is correct |
12 |
Correct |
24 ms |
856 KB |
Output is correct |
13 |
Correct |
24 ms |
856 KB |
Output is correct |
14 |
Correct |
24 ms |
836 KB |
Output is correct |
15 |
Correct |
42 ms |
824 KB |
Output is correct |
16 |
Correct |
33 ms |
848 KB |
Output is correct |
17 |
Correct |
42 ms |
816 KB |
Output is correct |
18 |
Correct |
34 ms |
860 KB |
Output is correct |
19 |
Correct |
44 ms |
884 KB |
Output is correct |
20 |
Correct |
46 ms |
856 KB |
Output is correct |
21 |
Correct |
25 ms |
920 KB |
Output is correct |
22 |
Correct |
40 ms |
868 KB |
Output is correct |
23 |
Correct |
25 ms |
928 KB |
Output is correct |
24 |
Correct |
27 ms |
860 KB |
Output is correct |
25 |
Correct |
45 ms |
848 KB |
Output is correct |
26 |
Correct |
23 ms |
860 KB |
Output is correct |
27 |
Correct |
33 ms |
860 KB |
Output is correct |
28 |
Correct |
23 ms |
856 KB |
Output is correct |
29 |
Correct |
29 ms |
860 KB |
Output is correct |
30 |
Correct |
22 ms |
860 KB |
Output is correct |
31 |
Correct |
27 ms |
936 KB |
Output is correct |
32 |
Correct |
26 ms |
916 KB |
Output is correct |
33 |
Correct |
27 ms |
932 KB |
Output is correct |
34 |
Correct |
29 ms |
856 KB |
Output is correct |
35 |
Correct |
26 ms |
908 KB |
Output is correct |
36 |
Correct |
26 ms |
856 KB |
Output is correct |
37 |
Correct |
26 ms |
860 KB |
Output is correct |
38 |
Correct |
54 ms |
848 KB |
Output is correct |
39 |
Correct |
29 ms |
820 KB |
Output is correct |
40 |
Correct |
25 ms |
1044 KB |
Output is correct |
41 |
Correct |
26 ms |
912 KB |
Output is correct |
42 |
Correct |
25 ms |
856 KB |
Output is correct |
43 |
Correct |
25 ms |
856 KB |
Output is correct |
44 |
Correct |
26 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
852 KB |
Output is correct |
2 |
Correct |
24 ms |
856 KB |
Output is correct |
3 |
Correct |
43 ms |
852 KB |
Output is correct |
4 |
Correct |
23 ms |
856 KB |
Output is correct |
5 |
Correct |
24 ms |
860 KB |
Output is correct |
6 |
Correct |
39 ms |
856 KB |
Output is correct |
7 |
Correct |
23 ms |
864 KB |
Output is correct |
8 |
Correct |
25 ms |
856 KB |
Output is correct |
9 |
Correct |
23 ms |
860 KB |
Output is correct |
10 |
Correct |
26 ms |
856 KB |
Output is correct |
11 |
Correct |
23 ms |
860 KB |
Output is correct |
12 |
Correct |
24 ms |
856 KB |
Output is correct |
13 |
Correct |
24 ms |
856 KB |
Output is correct |
14 |
Correct |
24 ms |
836 KB |
Output is correct |
15 |
Correct |
42 ms |
824 KB |
Output is correct |
16 |
Correct |
33 ms |
848 KB |
Output is correct |
17 |
Correct |
42 ms |
816 KB |
Output is correct |
18 |
Correct |
34 ms |
860 KB |
Output is correct |
19 |
Correct |
3648 ms |
2284 KB |
Output is correct |
20 |
Execution timed out |
7071 ms |
2216 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |