#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
string merge(string a, string b) {
string c = "";
for (int i = 0; i < a.size(); i++) {
if (a[i] == b[i]) c += a[i];
else {
set<char> f;
f.insert(a[i]);
f.insert(b[i]);
if (!f.count('J')) c += "J";
if (!f.count('O')) c += "O";
if (!f.count('I')) c += "I";
}
}
return c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
string s[3];
for (int i = 0; i < 3; i++) cin >> s[i];
set<string> all;
all.insert(s[0]);
all.insert(s[1]);
all.insert(s[2]);
all.insert(merge(s[0], s[1]));
all.insert(merge(s[0], s[2]));
all.insert(merge(s[1], s[2]));
all.insert(merge(s[0], merge(s[1], s[2])));
all.insert(merge(s[1], merge(s[0], s[2])));
all.insert(merge(s[2], merge(s[0], s[1])));
int q;
cin >> q;
string t;
cin >> t;
cout << (all.count(t) ? "Yes" : "No") << endl;
while (q--) {
int l, r;
char x;
cin >> l >> r >> x;
l--;
r--;
for (int i = l; i <= r; i++) {
t[i] = x;
}
cout << (all.count(t) ? "Yes" : "No") << endl;
}
}
Compilation message
Main.cpp: In function 'std::string merge(std::string, std::string)':
Main.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
2396 KB |
Output is correct |
3 |
Correct |
43 ms |
2240 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
33 ms |
2384 KB |
Output is correct |
6 |
Correct |
32 ms |
2388 KB |
Output is correct |
7 |
Correct |
33 ms |
2384 KB |
Output is correct |
8 |
Correct |
46 ms |
2384 KB |
Output is correct |
9 |
Correct |
34 ms |
2384 KB |
Output is correct |
10 |
Correct |
34 ms |
2384 KB |
Output is correct |
11 |
Correct |
37 ms |
2384 KB |
Output is correct |
12 |
Correct |
38 ms |
2492 KB |
Output is correct |
13 |
Correct |
39 ms |
2388 KB |
Output is correct |
14 |
Correct |
34 ms |
2392 KB |
Output is correct |
15 |
Correct |
35 ms |
2584 KB |
Output is correct |
16 |
Correct |
42 ms |
2460 KB |
Output is correct |
17 |
Correct |
38 ms |
2384 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
2396 KB |
Output is correct |
3 |
Correct |
43 ms |
2240 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
33 ms |
2384 KB |
Output is correct |
6 |
Correct |
32 ms |
2388 KB |
Output is correct |
7 |
Correct |
33 ms |
2384 KB |
Output is correct |
8 |
Correct |
46 ms |
2384 KB |
Output is correct |
9 |
Correct |
34 ms |
2384 KB |
Output is correct |
10 |
Correct |
34 ms |
2384 KB |
Output is correct |
11 |
Correct |
37 ms |
2384 KB |
Output is correct |
12 |
Correct |
38 ms |
2492 KB |
Output is correct |
13 |
Correct |
39 ms |
2388 KB |
Output is correct |
14 |
Correct |
34 ms |
2392 KB |
Output is correct |
15 |
Correct |
35 ms |
2584 KB |
Output is correct |
16 |
Correct |
42 ms |
2460 KB |
Output is correct |
17 |
Correct |
38 ms |
2384 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
3168 ms |
5604 KB |
Output is correct |
20 |
Execution timed out |
7006 ms |
3252 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
2396 KB |
Output is correct |
3 |
Correct |
43 ms |
2240 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
33 ms |
2384 KB |
Output is correct |
6 |
Correct |
32 ms |
2388 KB |
Output is correct |
7 |
Correct |
33 ms |
2384 KB |
Output is correct |
8 |
Correct |
46 ms |
2384 KB |
Output is correct |
9 |
Correct |
34 ms |
2384 KB |
Output is correct |
10 |
Correct |
34 ms |
2384 KB |
Output is correct |
11 |
Correct |
37 ms |
2384 KB |
Output is correct |
12 |
Correct |
38 ms |
2492 KB |
Output is correct |
13 |
Correct |
39 ms |
2388 KB |
Output is correct |
14 |
Correct |
34 ms |
2392 KB |
Output is correct |
15 |
Correct |
35 ms |
2584 KB |
Output is correct |
16 |
Correct |
42 ms |
2460 KB |
Output is correct |
17 |
Correct |
38 ms |
2384 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
38 ms |
2388 KB |
Output is correct |
20 |
Correct |
47 ms |
2380 KB |
Output is correct |
21 |
Correct |
36 ms |
2380 KB |
Output is correct |
22 |
Correct |
32 ms |
2140 KB |
Output is correct |
23 |
Correct |
35 ms |
2396 KB |
Output is correct |
24 |
Correct |
36 ms |
2320 KB |
Output is correct |
25 |
Correct |
41 ms |
2396 KB |
Output is correct |
26 |
Correct |
34 ms |
2248 KB |
Output is correct |
27 |
Correct |
36 ms |
2388 KB |
Output is correct |
28 |
Correct |
42 ms |
2336 KB |
Output is correct |
29 |
Correct |
37 ms |
2384 KB |
Output is correct |
30 |
Correct |
33 ms |
2224 KB |
Output is correct |
31 |
Correct |
38 ms |
2388 KB |
Output is correct |
32 |
Correct |
38 ms |
2388 KB |
Output is correct |
33 |
Correct |
38 ms |
2524 KB |
Output is correct |
34 |
Correct |
42 ms |
2388 KB |
Output is correct |
35 |
Correct |
41 ms |
2388 KB |
Output is correct |
36 |
Correct |
39 ms |
2384 KB |
Output is correct |
37 |
Correct |
39 ms |
2384 KB |
Output is correct |
38 |
Correct |
39 ms |
2520 KB |
Output is correct |
39 |
Correct |
40 ms |
2396 KB |
Output is correct |
40 |
Correct |
40 ms |
2384 KB |
Output is correct |
41 |
Correct |
38 ms |
2548 KB |
Output is correct |
42 |
Correct |
37 ms |
2388 KB |
Output is correct |
43 |
Correct |
36 ms |
2396 KB |
Output is correct |
44 |
Correct |
38 ms |
2336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
2396 KB |
Output is correct |
3 |
Correct |
43 ms |
2240 KB |
Output is correct |
4 |
Correct |
34 ms |
2476 KB |
Output is correct |
5 |
Correct |
33 ms |
2384 KB |
Output is correct |
6 |
Correct |
32 ms |
2388 KB |
Output is correct |
7 |
Correct |
33 ms |
2384 KB |
Output is correct |
8 |
Correct |
46 ms |
2384 KB |
Output is correct |
9 |
Correct |
34 ms |
2384 KB |
Output is correct |
10 |
Correct |
34 ms |
2384 KB |
Output is correct |
11 |
Correct |
37 ms |
2384 KB |
Output is correct |
12 |
Correct |
38 ms |
2492 KB |
Output is correct |
13 |
Correct |
39 ms |
2388 KB |
Output is correct |
14 |
Correct |
34 ms |
2392 KB |
Output is correct |
15 |
Correct |
35 ms |
2584 KB |
Output is correct |
16 |
Correct |
42 ms |
2460 KB |
Output is correct |
17 |
Correct |
38 ms |
2384 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
3168 ms |
5604 KB |
Output is correct |
20 |
Execution timed out |
7006 ms |
3252 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |