#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
map<string, int> vis;
queue<string> q;
string ini[3];
string spoj(string a, string b){
string ret = a;
for(int i = 0; i < (int)a.size(); i++){
if(a[i] == b[i]) ret[i] = a[i];
else ret[i] = 'J' + 'I' + 'O' - a[i] - b[i];
}
return ret;
}
void bfs(){
while(!q.empty()){
string sega = q.front();
q.pop();
for(int i = 0; i < 3; i++){
string spoeno = spoj(sega, ini[i]);
if(!vis[spoeno]){
vis[spoeno] = 1;
q.push(spoeno);
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n>>ini[0]>>ini[1]>>ini[2];
for(int i = 0; i < 3; i++){
q.push(ini[i]);
vis[ini[i]] = 1;
}
bfs();
int q;
cin>>q;
string str;
cin>>str;
if(vis[str]) cout<<"Yes\n";
else cout<<"No\n";
while(q--){
int l, r;
char c;
cin>>l>>r>>c;
l--; r--;
for(int i = l; i <= r; i++) str[i] = c;
if(vis[str]) cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
27688 KB |
Output is correct |
2 |
Correct |
117 ms |
32332 KB |
Output is correct |
3 |
Correct |
92 ms |
12880 KB |
Output is correct |
4 |
Correct |
135 ms |
32308 KB |
Output is correct |
5 |
Correct |
119 ms |
32852 KB |
Output is correct |
6 |
Correct |
112 ms |
30288 KB |
Output is correct |
7 |
Correct |
110 ms |
28788 KB |
Output is correct |
8 |
Correct |
134 ms |
33516 KB |
Output is correct |
9 |
Correct |
129 ms |
32080 KB |
Output is correct |
10 |
Correct |
122 ms |
36516 KB |
Output is correct |
11 |
Correct |
119 ms |
34284 KB |
Output is correct |
12 |
Correct |
120 ms |
36688 KB |
Output is correct |
13 |
Correct |
118 ms |
34384 KB |
Output is correct |
14 |
Correct |
124 ms |
36688 KB |
Output is correct |
15 |
Correct |
137 ms |
34420 KB |
Output is correct |
16 |
Correct |
123 ms |
36688 KB |
Output is correct |
17 |
Correct |
114 ms |
34384 KB |
Output is correct |
18 |
Correct |
81 ms |
8016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
27688 KB |
Output is correct |
2 |
Correct |
117 ms |
32332 KB |
Output is correct |
3 |
Correct |
92 ms |
12880 KB |
Output is correct |
4 |
Correct |
135 ms |
32308 KB |
Output is correct |
5 |
Correct |
119 ms |
32852 KB |
Output is correct |
6 |
Correct |
112 ms |
30288 KB |
Output is correct |
7 |
Correct |
110 ms |
28788 KB |
Output is correct |
8 |
Correct |
134 ms |
33516 KB |
Output is correct |
9 |
Correct |
129 ms |
32080 KB |
Output is correct |
10 |
Correct |
122 ms |
36516 KB |
Output is correct |
11 |
Correct |
119 ms |
34284 KB |
Output is correct |
12 |
Correct |
120 ms |
36688 KB |
Output is correct |
13 |
Correct |
118 ms |
34384 KB |
Output is correct |
14 |
Correct |
124 ms |
36688 KB |
Output is correct |
15 |
Correct |
137 ms |
34420 KB |
Output is correct |
16 |
Correct |
123 ms |
36688 KB |
Output is correct |
17 |
Correct |
114 ms |
34384 KB |
Output is correct |
18 |
Correct |
81 ms |
8016 KB |
Output is correct |
19 |
Runtime error |
624 ms |
1048576 KB |
Execution killed with signal 9 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
27688 KB |
Output is correct |
2 |
Correct |
117 ms |
32332 KB |
Output is correct |
3 |
Correct |
92 ms |
12880 KB |
Output is correct |
4 |
Correct |
135 ms |
32308 KB |
Output is correct |
5 |
Correct |
119 ms |
32852 KB |
Output is correct |
6 |
Correct |
112 ms |
30288 KB |
Output is correct |
7 |
Correct |
110 ms |
28788 KB |
Output is correct |
8 |
Correct |
134 ms |
33516 KB |
Output is correct |
9 |
Correct |
129 ms |
32080 KB |
Output is correct |
10 |
Correct |
122 ms |
36516 KB |
Output is correct |
11 |
Correct |
119 ms |
34284 KB |
Output is correct |
12 |
Correct |
120 ms |
36688 KB |
Output is correct |
13 |
Correct |
118 ms |
34384 KB |
Output is correct |
14 |
Correct |
124 ms |
36688 KB |
Output is correct |
15 |
Correct |
137 ms |
34420 KB |
Output is correct |
16 |
Correct |
123 ms |
36688 KB |
Output is correct |
17 |
Correct |
114 ms |
34384 KB |
Output is correct |
18 |
Correct |
81 ms |
8016 KB |
Output is correct |
19 |
Correct |
117 ms |
31512 KB |
Output is correct |
20 |
Correct |
95 ms |
13396 KB |
Output is correct |
21 |
Correct |
144 ms |
35412 KB |
Output is correct |
22 |
Correct |
107 ms |
25232 KB |
Output is correct |
23 |
Correct |
130 ms |
35668 KB |
Output is correct |
24 |
Correct |
124 ms |
32324 KB |
Output is correct |
25 |
Correct |
126 ms |
35156 KB |
Output is correct |
26 |
Correct |
107 ms |
26420 KB |
Output is correct |
27 |
Correct |
136 ms |
35472 KB |
Output is correct |
28 |
Correct |
113 ms |
32216 KB |
Output is correct |
29 |
Correct |
123 ms |
33432 KB |
Output is correct |
30 |
Correct |
105 ms |
25572 KB |
Output is correct |
31 |
Correct |
129 ms |
36108 KB |
Output is correct |
32 |
Correct |
134 ms |
35616 KB |
Output is correct |
33 |
Correct |
121 ms |
34128 KB |
Output is correct |
34 |
Correct |
112 ms |
28800 KB |
Output is correct |
35 |
Correct |
132 ms |
37240 KB |
Output is correct |
36 |
Correct |
117 ms |
34900 KB |
Output is correct |
37 |
Correct |
125 ms |
37120 KB |
Output is correct |
38 |
Correct |
118 ms |
34772 KB |
Output is correct |
39 |
Correct |
127 ms |
37276 KB |
Output is correct |
40 |
Correct |
117 ms |
34896 KB |
Output is correct |
41 |
Correct |
123 ms |
37204 KB |
Output is correct |
42 |
Correct |
118 ms |
34792 KB |
Output is correct |
43 |
Correct |
125 ms |
30168 KB |
Output is correct |
44 |
Correct |
124 ms |
33948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
27688 KB |
Output is correct |
2 |
Correct |
117 ms |
32332 KB |
Output is correct |
3 |
Correct |
92 ms |
12880 KB |
Output is correct |
4 |
Correct |
135 ms |
32308 KB |
Output is correct |
5 |
Correct |
119 ms |
32852 KB |
Output is correct |
6 |
Correct |
112 ms |
30288 KB |
Output is correct |
7 |
Correct |
110 ms |
28788 KB |
Output is correct |
8 |
Correct |
134 ms |
33516 KB |
Output is correct |
9 |
Correct |
129 ms |
32080 KB |
Output is correct |
10 |
Correct |
122 ms |
36516 KB |
Output is correct |
11 |
Correct |
119 ms |
34284 KB |
Output is correct |
12 |
Correct |
120 ms |
36688 KB |
Output is correct |
13 |
Correct |
118 ms |
34384 KB |
Output is correct |
14 |
Correct |
124 ms |
36688 KB |
Output is correct |
15 |
Correct |
137 ms |
34420 KB |
Output is correct |
16 |
Correct |
123 ms |
36688 KB |
Output is correct |
17 |
Correct |
114 ms |
34384 KB |
Output is correct |
18 |
Correct |
81 ms |
8016 KB |
Output is correct |
19 |
Runtime error |
624 ms |
1048576 KB |
Execution killed with signal 9 |
20 |
Halted |
0 ms |
0 KB |
- |