#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n")
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int inf = 2e09; ll infll = 2e18;
vector<string> get_strings(string &xx, string &y, string &z){
string s[3] = {xx, y, z};
int n = int(s[0].length());
map<string, int> mp;
queue<string> q;
for(int l = 0; l < 3; ++l) mp[s[l]] = 1, q.emplace(s[l]);
char t[3] = {'J', 'O', 'I'};
//~ int cnt = 0;
vector<string> ret;
while(!q.empty()){
string x = q.front(); q.pop();
string tt = ""; tt.resize(n);
for(int l = 0; l < 3; ++l){
for(int i = 0; i < n; ++i) if(x[i] == s[l][i]) tt[i] = x[i];
else{
int a, b;
for(int j = 0; j < 3; ++j) if(t[j] == x[i]) a = j;
for(int j = 0; j < 3; ++j) if(t[j] == s[l][i]) b = j;
if(a && b) tt[i] = t[0];
else if(max(a, b) > 1) tt[i] = t[1];
else tt[i] = t[2];
}
if(mp[tt] != 1) mp[tt] = 1, q.emplace(tt); //, cout << ":\n" << x << "\n" << s[l] << "\n" << tt << "\n\n";
}
//~ cout << x << "\n";
ret.emplace_back(x);
}
return ret;
}
void answer(){
int n, q; scanf("%d", &n);
string s[3] = {"", "", ""}, t="";
char c;
for(int l = 0; l < 3; ++l){
c = getchar_unlocked();
for(int i = 0; i < n; ++i) c = getchar_unlocked(), s[l] += c;
}
scanf("%d\n", &q);
for(int i = 0; i < n; ++i) c = getchar_unlocked(), t += c;
vector<string> st = get_strings(s[0], s[1], s[2]);
bool good = 0;
for(string u : st){
if(t == u) good = 1;
}
printf(good ? "Yes\n" : "No\n");
for(int i = 0; i < q; ++i){
int a, b;
scanf("%d%d %c", &a, &b, &c);
for(int j = a-1; j < b; ++j) t[j] = c;
good = 0;
for(string &u : st) if(t == u) good = 1;
printf(good ? "Yes\n" : "No\n");
}
}
int main(){
int T = 1;
//~ ios_base::sync_with_stdio(0); cin.tie(0);
for(++T; --T; ) answer();
return 0;
}
Compilation message
Main.cpp: In function 'void answer()':
Main.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | int n, q; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Main.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | scanf("%d\n", &q);
| ~~~~~^~~~~~~~~~~~
Main.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
58 | scanf("%d%d %c", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2184 KB |
Output is correct |
2 |
Correct |
46 ms |
2364 KB |
Output is correct |
3 |
Correct |
51 ms |
2384 KB |
Output is correct |
4 |
Correct |
59 ms |
2460 KB |
Output is correct |
5 |
Correct |
41 ms |
2340 KB |
Output is correct |
6 |
Correct |
40 ms |
2308 KB |
Output is correct |
7 |
Correct |
48 ms |
2388 KB |
Output is correct |
8 |
Correct |
55 ms |
2332 KB |
Output is correct |
9 |
Correct |
52 ms |
2476 KB |
Output is correct |
10 |
Correct |
43 ms |
2384 KB |
Output is correct |
11 |
Correct |
43 ms |
2424 KB |
Output is correct |
12 |
Correct |
42 ms |
2384 KB |
Output is correct |
13 |
Correct |
41 ms |
2364 KB |
Output is correct |
14 |
Correct |
43 ms |
2440 KB |
Output is correct |
15 |
Correct |
46 ms |
2396 KB |
Output is correct |
16 |
Correct |
48 ms |
2388 KB |
Output is correct |
17 |
Correct |
43 ms |
2392 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2184 KB |
Output is correct |
2 |
Correct |
46 ms |
2364 KB |
Output is correct |
3 |
Correct |
51 ms |
2384 KB |
Output is correct |
4 |
Correct |
59 ms |
2460 KB |
Output is correct |
5 |
Correct |
41 ms |
2340 KB |
Output is correct |
6 |
Correct |
40 ms |
2308 KB |
Output is correct |
7 |
Correct |
48 ms |
2388 KB |
Output is correct |
8 |
Correct |
55 ms |
2332 KB |
Output is correct |
9 |
Correct |
52 ms |
2476 KB |
Output is correct |
10 |
Correct |
43 ms |
2384 KB |
Output is correct |
11 |
Correct |
43 ms |
2424 KB |
Output is correct |
12 |
Correct |
42 ms |
2384 KB |
Output is correct |
13 |
Correct |
41 ms |
2364 KB |
Output is correct |
14 |
Correct |
43 ms |
2440 KB |
Output is correct |
15 |
Correct |
46 ms |
2396 KB |
Output is correct |
16 |
Correct |
48 ms |
2388 KB |
Output is correct |
17 |
Correct |
43 ms |
2392 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
3278 ms |
6484 KB |
Output is correct |
20 |
Execution timed out |
7085 ms |
4172 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2184 KB |
Output is correct |
2 |
Correct |
46 ms |
2364 KB |
Output is correct |
3 |
Correct |
51 ms |
2384 KB |
Output is correct |
4 |
Correct |
59 ms |
2460 KB |
Output is correct |
5 |
Correct |
41 ms |
2340 KB |
Output is correct |
6 |
Correct |
40 ms |
2308 KB |
Output is correct |
7 |
Correct |
48 ms |
2388 KB |
Output is correct |
8 |
Correct |
55 ms |
2332 KB |
Output is correct |
9 |
Correct |
52 ms |
2476 KB |
Output is correct |
10 |
Correct |
43 ms |
2384 KB |
Output is correct |
11 |
Correct |
43 ms |
2424 KB |
Output is correct |
12 |
Correct |
42 ms |
2384 KB |
Output is correct |
13 |
Correct |
41 ms |
2364 KB |
Output is correct |
14 |
Correct |
43 ms |
2440 KB |
Output is correct |
15 |
Correct |
46 ms |
2396 KB |
Output is correct |
16 |
Correct |
48 ms |
2388 KB |
Output is correct |
17 |
Correct |
43 ms |
2392 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
47 ms |
2232 KB |
Output is correct |
20 |
Correct |
55 ms |
2244 KB |
Output is correct |
21 |
Correct |
46 ms |
2372 KB |
Output is correct |
22 |
Correct |
49 ms |
2188 KB |
Output is correct |
23 |
Correct |
65 ms |
2352 KB |
Output is correct |
24 |
Correct |
44 ms |
2432 KB |
Output is correct |
25 |
Correct |
43 ms |
2384 KB |
Output is correct |
26 |
Correct |
41 ms |
2348 KB |
Output is correct |
27 |
Correct |
46 ms |
2384 KB |
Output is correct |
28 |
Correct |
40 ms |
2128 KB |
Output is correct |
29 |
Correct |
42 ms |
2388 KB |
Output is correct |
30 |
Correct |
41 ms |
2352 KB |
Output is correct |
31 |
Correct |
55 ms |
2652 KB |
Output is correct |
32 |
Correct |
49 ms |
2460 KB |
Output is correct |
33 |
Correct |
48 ms |
2384 KB |
Output is correct |
34 |
Correct |
42 ms |
2388 KB |
Output is correct |
35 |
Correct |
47 ms |
2532 KB |
Output is correct |
36 |
Correct |
46 ms |
2516 KB |
Output is correct |
37 |
Correct |
46 ms |
2384 KB |
Output is correct |
38 |
Correct |
51 ms |
2340 KB |
Output is correct |
39 |
Correct |
47 ms |
2528 KB |
Output is correct |
40 |
Correct |
46 ms |
2552 KB |
Output is correct |
41 |
Correct |
56 ms |
2540 KB |
Output is correct |
42 |
Correct |
46 ms |
2460 KB |
Output is correct |
43 |
Correct |
48 ms |
2388 KB |
Output is correct |
44 |
Correct |
54 ms |
2532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
2184 KB |
Output is correct |
2 |
Correct |
46 ms |
2364 KB |
Output is correct |
3 |
Correct |
51 ms |
2384 KB |
Output is correct |
4 |
Correct |
59 ms |
2460 KB |
Output is correct |
5 |
Correct |
41 ms |
2340 KB |
Output is correct |
6 |
Correct |
40 ms |
2308 KB |
Output is correct |
7 |
Correct |
48 ms |
2388 KB |
Output is correct |
8 |
Correct |
55 ms |
2332 KB |
Output is correct |
9 |
Correct |
52 ms |
2476 KB |
Output is correct |
10 |
Correct |
43 ms |
2384 KB |
Output is correct |
11 |
Correct |
43 ms |
2424 KB |
Output is correct |
12 |
Correct |
42 ms |
2384 KB |
Output is correct |
13 |
Correct |
41 ms |
2364 KB |
Output is correct |
14 |
Correct |
43 ms |
2440 KB |
Output is correct |
15 |
Correct |
46 ms |
2396 KB |
Output is correct |
16 |
Correct |
48 ms |
2388 KB |
Output is correct |
17 |
Correct |
43 ms |
2392 KB |
Output is correct |
18 |
Correct |
53 ms |
2388 KB |
Output is correct |
19 |
Correct |
3278 ms |
6484 KB |
Output is correct |
20 |
Execution timed out |
7085 ms |
4172 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |