#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 2;
int n, q;
bool ans[MAXN];
struct Change {
int l, r;
char c;
} a[MAXN];
string poc[3];
string t;
string comp(string& a, string& b){
string ret = "";
for(int i = 0; i < n; ++i){
if(a[i] == b[i]) ret += a[i];
else for(char c : {'J', 'O', 'I'}){
if(c != a[i] && c != b[i]) ret += c;
}
}
return ret;
}
void solve(string s){
string cur = t;
ans[0] |= (s == cur);
for(int i = 1; i <= q; ++i){
for(int j = a[i].l; j <= a[i].r; ++j){
cur[j] = a[i].c;
}
ans[i] |= (s == cur);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for(int i = 0; i < 3; ++i) cin >> poc[i];
cin >> q >> t;
for(int i = 1; i <= q; ++i){
cin >> a[i].l >> a[i].r >> a[i].c;
--a[i].l, --a[i].r;
}
for(int i = 1; i < 8; ++i){
string cur = "";
vector<int> tmp;
for(int j = 0; j < 3; ++j){
if(i & 1 << j){
tmp.push_back(j);
}
}
do{
cur = poc[tmp[0]];
for(int j = 1; j < (int)tmp.size(); ++j) cur = comp(cur, poc[tmp[j]]);
solve(cur);
} while(next_permutation(tmp.begin(), tmp.end()));
}
for(int i = 0; i <= q; ++i){
if(ans[i]) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
4600 KB |
Output is correct |
2 |
Correct |
207 ms |
4908 KB |
Output is correct |
3 |
Correct |
757 ms |
4768 KB |
Output is correct |
4 |
Correct |
183 ms |
4780 KB |
Output is correct |
5 |
Correct |
182 ms |
4748 KB |
Output is correct |
6 |
Correct |
174 ms |
4684 KB |
Output is correct |
7 |
Correct |
178 ms |
4940 KB |
Output is correct |
8 |
Correct |
212 ms |
4888 KB |
Output is correct |
9 |
Correct |
170 ms |
4892 KB |
Output is correct |
10 |
Correct |
207 ms |
4896 KB |
Output is correct |
11 |
Correct |
215 ms |
4896 KB |
Output is correct |
12 |
Correct |
207 ms |
4940 KB |
Output is correct |
13 |
Correct |
184 ms |
4900 KB |
Output is correct |
14 |
Correct |
200 ms |
4900 KB |
Output is correct |
15 |
Correct |
185 ms |
4896 KB |
Output is correct |
16 |
Correct |
218 ms |
4896 KB |
Output is correct |
17 |
Correct |
182 ms |
4892 KB |
Output is correct |
18 |
Correct |
829 ms |
4804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
4600 KB |
Output is correct |
2 |
Correct |
207 ms |
4908 KB |
Output is correct |
3 |
Correct |
757 ms |
4768 KB |
Output is correct |
4 |
Correct |
183 ms |
4780 KB |
Output is correct |
5 |
Correct |
182 ms |
4748 KB |
Output is correct |
6 |
Correct |
174 ms |
4684 KB |
Output is correct |
7 |
Correct |
178 ms |
4940 KB |
Output is correct |
8 |
Correct |
212 ms |
4888 KB |
Output is correct |
9 |
Correct |
170 ms |
4892 KB |
Output is correct |
10 |
Correct |
207 ms |
4896 KB |
Output is correct |
11 |
Correct |
215 ms |
4896 KB |
Output is correct |
12 |
Correct |
207 ms |
4940 KB |
Output is correct |
13 |
Correct |
184 ms |
4900 KB |
Output is correct |
14 |
Correct |
200 ms |
4900 KB |
Output is correct |
15 |
Correct |
185 ms |
4896 KB |
Output is correct |
16 |
Correct |
218 ms |
4896 KB |
Output is correct |
17 |
Correct |
182 ms |
4892 KB |
Output is correct |
18 |
Correct |
829 ms |
4804 KB |
Output is correct |
19 |
Execution timed out |
7063 ms |
8216 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
4600 KB |
Output is correct |
2 |
Correct |
207 ms |
4908 KB |
Output is correct |
3 |
Correct |
757 ms |
4768 KB |
Output is correct |
4 |
Correct |
183 ms |
4780 KB |
Output is correct |
5 |
Correct |
182 ms |
4748 KB |
Output is correct |
6 |
Correct |
174 ms |
4684 KB |
Output is correct |
7 |
Correct |
178 ms |
4940 KB |
Output is correct |
8 |
Correct |
212 ms |
4888 KB |
Output is correct |
9 |
Correct |
170 ms |
4892 KB |
Output is correct |
10 |
Correct |
207 ms |
4896 KB |
Output is correct |
11 |
Correct |
215 ms |
4896 KB |
Output is correct |
12 |
Correct |
207 ms |
4940 KB |
Output is correct |
13 |
Correct |
184 ms |
4900 KB |
Output is correct |
14 |
Correct |
200 ms |
4900 KB |
Output is correct |
15 |
Correct |
185 ms |
4896 KB |
Output is correct |
16 |
Correct |
218 ms |
4896 KB |
Output is correct |
17 |
Correct |
182 ms |
4892 KB |
Output is correct |
18 |
Correct |
829 ms |
4804 KB |
Output is correct |
19 |
Correct |
200 ms |
4720 KB |
Output is correct |
20 |
Correct |
779 ms |
4768 KB |
Output is correct |
21 |
Correct |
198 ms |
4944 KB |
Output is correct |
22 |
Correct |
142 ms |
4564 KB |
Output is correct |
23 |
Correct |
190 ms |
4892 KB |
Output is correct |
24 |
Correct |
165 ms |
4768 KB |
Output is correct |
25 |
Correct |
205 ms |
4888 KB |
Output is correct |
26 |
Correct |
152 ms |
4728 KB |
Output is correct |
27 |
Correct |
198 ms |
4940 KB |
Output is correct |
28 |
Correct |
174 ms |
4592 KB |
Output is correct |
29 |
Correct |
176 ms |
4900 KB |
Output is correct |
30 |
Correct |
148 ms |
4592 KB |
Output is correct |
31 |
Correct |
201 ms |
4896 KB |
Output is correct |
32 |
Correct |
193 ms |
4944 KB |
Output is correct |
33 |
Correct |
178 ms |
4896 KB |
Output is correct |
34 |
Correct |
150 ms |
4676 KB |
Output is correct |
35 |
Correct |
201 ms |
4900 KB |
Output is correct |
36 |
Correct |
185 ms |
4904 KB |
Output is correct |
37 |
Correct |
201 ms |
4944 KB |
Output is correct |
38 |
Correct |
176 ms |
4896 KB |
Output is correct |
39 |
Correct |
197 ms |
4896 KB |
Output is correct |
40 |
Correct |
178 ms |
4960 KB |
Output is correct |
41 |
Correct |
207 ms |
4984 KB |
Output is correct |
42 |
Correct |
174 ms |
4860 KB |
Output is correct |
43 |
Correct |
153 ms |
4812 KB |
Output is correct |
44 |
Correct |
182 ms |
4952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
4600 KB |
Output is correct |
2 |
Correct |
207 ms |
4908 KB |
Output is correct |
3 |
Correct |
757 ms |
4768 KB |
Output is correct |
4 |
Correct |
183 ms |
4780 KB |
Output is correct |
5 |
Correct |
182 ms |
4748 KB |
Output is correct |
6 |
Correct |
174 ms |
4684 KB |
Output is correct |
7 |
Correct |
178 ms |
4940 KB |
Output is correct |
8 |
Correct |
212 ms |
4888 KB |
Output is correct |
9 |
Correct |
170 ms |
4892 KB |
Output is correct |
10 |
Correct |
207 ms |
4896 KB |
Output is correct |
11 |
Correct |
215 ms |
4896 KB |
Output is correct |
12 |
Correct |
207 ms |
4940 KB |
Output is correct |
13 |
Correct |
184 ms |
4900 KB |
Output is correct |
14 |
Correct |
200 ms |
4900 KB |
Output is correct |
15 |
Correct |
185 ms |
4896 KB |
Output is correct |
16 |
Correct |
218 ms |
4896 KB |
Output is correct |
17 |
Correct |
182 ms |
4892 KB |
Output is correct |
18 |
Correct |
829 ms |
4804 KB |
Output is correct |
19 |
Execution timed out |
7063 ms |
8216 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |