#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string cross(string &a, string &b) {
string res(a.size(), 'a');
for (int i = 0; i < a.size(); ++i) {
if (a[i] == b[i]) {
res[i] = a[i];
} else {
res[i] = 'J' ^ 'O' ^ 'I' ^ a[i] ^ b[i];
}
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string A, B, C;
cin >> A >> B >> C;
unordered_set<string> every{A, B, C};
queue<string> qu;
qu.push(A), qu.push(B), qu.push(C);
while (!qu.empty()) {
string s = qu.front();
qu.pop();
for (string to : every) {
string res = cross(s, to);
if (!every.count(res)) {
qu.push(res);
every.insert(res);
}
}
}
int q;
cin >> q;
string t;
cin >> t;
cout << (every.count(t) ? "Yes\n" : "No\n");
while (q--) {
int l, r;
char c;
cin >> l >> r >> c;
--l;
for (int i = l; i < r; ++i) {
t[i] = c;
}
cout << (every.count(t) ? "Yes\n" : "No\n");
}
return 0;
}
Compilation message
Main.cpp: In function 'std::string cross(std::string&, std::string&)':
Main.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for (int i = 0; i < a.size(); ++i) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
2392 KB |
Output is correct |
2 |
Correct |
48 ms |
2360 KB |
Output is correct |
3 |
Correct |
77 ms |
2260 KB |
Output is correct |
4 |
Correct |
47 ms |
2252 KB |
Output is correct |
5 |
Correct |
50 ms |
2276 KB |
Output is correct |
6 |
Correct |
46 ms |
2244 KB |
Output is correct |
7 |
Correct |
43 ms |
2348 KB |
Output is correct |
8 |
Correct |
47 ms |
2424 KB |
Output is correct |
9 |
Correct |
45 ms |
2408 KB |
Output is correct |
10 |
Correct |
54 ms |
2380 KB |
Output is correct |
11 |
Correct |
48 ms |
2360 KB |
Output is correct |
12 |
Correct |
51 ms |
2368 KB |
Output is correct |
13 |
Correct |
48 ms |
2424 KB |
Output is correct |
14 |
Correct |
46 ms |
2380 KB |
Output is correct |
15 |
Correct |
47 ms |
2376 KB |
Output is correct |
16 |
Correct |
48 ms |
2392 KB |
Output is correct |
17 |
Correct |
46 ms |
2384 KB |
Output is correct |
18 |
Correct |
80 ms |
2276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
2392 KB |
Output is correct |
2 |
Correct |
48 ms |
2360 KB |
Output is correct |
3 |
Correct |
77 ms |
2260 KB |
Output is correct |
4 |
Correct |
47 ms |
2252 KB |
Output is correct |
5 |
Correct |
50 ms |
2276 KB |
Output is correct |
6 |
Correct |
46 ms |
2244 KB |
Output is correct |
7 |
Correct |
43 ms |
2348 KB |
Output is correct |
8 |
Correct |
47 ms |
2424 KB |
Output is correct |
9 |
Correct |
45 ms |
2408 KB |
Output is correct |
10 |
Correct |
54 ms |
2380 KB |
Output is correct |
11 |
Correct |
48 ms |
2360 KB |
Output is correct |
12 |
Correct |
51 ms |
2368 KB |
Output is correct |
13 |
Correct |
48 ms |
2424 KB |
Output is correct |
14 |
Correct |
46 ms |
2380 KB |
Output is correct |
15 |
Correct |
47 ms |
2376 KB |
Output is correct |
16 |
Correct |
48 ms |
2392 KB |
Output is correct |
17 |
Correct |
46 ms |
2384 KB |
Output is correct |
18 |
Correct |
80 ms |
2276 KB |
Output is correct |
19 |
Execution timed out |
7034 ms |
4276 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
2392 KB |
Output is correct |
2 |
Correct |
48 ms |
2360 KB |
Output is correct |
3 |
Correct |
77 ms |
2260 KB |
Output is correct |
4 |
Correct |
47 ms |
2252 KB |
Output is correct |
5 |
Correct |
50 ms |
2276 KB |
Output is correct |
6 |
Correct |
46 ms |
2244 KB |
Output is correct |
7 |
Correct |
43 ms |
2348 KB |
Output is correct |
8 |
Correct |
47 ms |
2424 KB |
Output is correct |
9 |
Correct |
45 ms |
2408 KB |
Output is correct |
10 |
Correct |
54 ms |
2380 KB |
Output is correct |
11 |
Correct |
48 ms |
2360 KB |
Output is correct |
12 |
Correct |
51 ms |
2368 KB |
Output is correct |
13 |
Correct |
48 ms |
2424 KB |
Output is correct |
14 |
Correct |
46 ms |
2380 KB |
Output is correct |
15 |
Correct |
47 ms |
2376 KB |
Output is correct |
16 |
Correct |
48 ms |
2392 KB |
Output is correct |
17 |
Correct |
46 ms |
2384 KB |
Output is correct |
18 |
Correct |
80 ms |
2276 KB |
Output is correct |
19 |
Correct |
46 ms |
2252 KB |
Output is correct |
20 |
Correct |
80 ms |
2356 KB |
Output is correct |
21 |
Correct |
54 ms |
2368 KB |
Output is correct |
22 |
Correct |
42 ms |
2236 KB |
Output is correct |
23 |
Correct |
49 ms |
2380 KB |
Output is correct |
24 |
Correct |
49 ms |
2356 KB |
Output is correct |
25 |
Correct |
51 ms |
2380 KB |
Output is correct |
26 |
Correct |
46 ms |
2256 KB |
Output is correct |
27 |
Correct |
50 ms |
2372 KB |
Output is correct |
28 |
Correct |
42 ms |
2208 KB |
Output is correct |
29 |
Correct |
50 ms |
2412 KB |
Output is correct |
30 |
Correct |
45 ms |
2256 KB |
Output is correct |
31 |
Correct |
51 ms |
2412 KB |
Output is correct |
32 |
Correct |
47 ms |
2376 KB |
Output is correct |
33 |
Correct |
48 ms |
2400 KB |
Output is correct |
34 |
Correct |
43 ms |
2300 KB |
Output is correct |
35 |
Correct |
49 ms |
2456 KB |
Output is correct |
36 |
Correct |
48 ms |
2396 KB |
Output is correct |
37 |
Correct |
49 ms |
2372 KB |
Output is correct |
38 |
Correct |
52 ms |
2348 KB |
Output is correct |
39 |
Correct |
48 ms |
2400 KB |
Output is correct |
40 |
Correct |
46 ms |
2396 KB |
Output is correct |
41 |
Correct |
48 ms |
2392 KB |
Output is correct |
42 |
Correct |
49 ms |
2376 KB |
Output is correct |
43 |
Correct |
51 ms |
2380 KB |
Output is correct |
44 |
Correct |
50 ms |
2372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
2392 KB |
Output is correct |
2 |
Correct |
48 ms |
2360 KB |
Output is correct |
3 |
Correct |
77 ms |
2260 KB |
Output is correct |
4 |
Correct |
47 ms |
2252 KB |
Output is correct |
5 |
Correct |
50 ms |
2276 KB |
Output is correct |
6 |
Correct |
46 ms |
2244 KB |
Output is correct |
7 |
Correct |
43 ms |
2348 KB |
Output is correct |
8 |
Correct |
47 ms |
2424 KB |
Output is correct |
9 |
Correct |
45 ms |
2408 KB |
Output is correct |
10 |
Correct |
54 ms |
2380 KB |
Output is correct |
11 |
Correct |
48 ms |
2360 KB |
Output is correct |
12 |
Correct |
51 ms |
2368 KB |
Output is correct |
13 |
Correct |
48 ms |
2424 KB |
Output is correct |
14 |
Correct |
46 ms |
2380 KB |
Output is correct |
15 |
Correct |
47 ms |
2376 KB |
Output is correct |
16 |
Correct |
48 ms |
2392 KB |
Output is correct |
17 |
Correct |
46 ms |
2384 KB |
Output is correct |
18 |
Correct |
80 ms |
2276 KB |
Output is correct |
19 |
Execution timed out |
7034 ms |
4276 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |