#include<bits/stdc++.h>
using namespace std;
int n;
string c1, c2, c3;
unordered_set < string > st;
string action(string s1, string s2)
{
string res;
res.resize(n);
for (int i = 0; i < n; i ++)
{
if (s1[i] == s2[i])
res[i] = s1[i];
else
{
char c = 'J';
if (s1[i] == c || s2[i] == c)
c = 'O';
if (s1[i] == c || s2[i] == c)
c = 'I';
res[i] = c;
}
}
return res;
}
void brute(string s)
{
if (st.find(s) != st.end())
return;
st.insert(s);
brute(action(s, c1));
brute(action(s, c2));
brute(action(s, c3));
}
int q;
string t;
void solve()
{
cin >> n;
cin >> c1 >> c2 >> c3;
brute(c1);
brute(c2);
brute(c3);
//for (string cur : st)
// cout << cur << endl;
cin >> q >> t;
//cout << "find " << t << endl;
if (st.find(t) != st.end())
cout << "Yes" << endl;
else
cout << "No" << endl;
for (int i = 1; i <= q; i ++)
{
int l, r;
char c;
cin >> l >> r >> c;
for (int j = l - 1; j < r; j ++)
t[j] = c;
if (st.find(t) != st.end())
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
int main()
{
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
2384 KB |
Output is correct |
2 |
Correct |
270 ms |
2604 KB |
Output is correct |
3 |
Correct |
269 ms |
2244 KB |
Output is correct |
4 |
Correct |
263 ms |
2388 KB |
Output is correct |
5 |
Correct |
256 ms |
2248 KB |
Output is correct |
6 |
Correct |
248 ms |
2384 KB |
Output is correct |
7 |
Correct |
268 ms |
2504 KB |
Output is correct |
8 |
Correct |
277 ms |
2384 KB |
Output is correct |
9 |
Correct |
324 ms |
2384 KB |
Output is correct |
10 |
Correct |
291 ms |
2384 KB |
Output is correct |
11 |
Correct |
273 ms |
2384 KB |
Output is correct |
12 |
Correct |
263 ms |
2412 KB |
Output is correct |
13 |
Correct |
275 ms |
2636 KB |
Output is correct |
14 |
Correct |
266 ms |
2312 KB |
Output is correct |
15 |
Correct |
266 ms |
2588 KB |
Output is correct |
16 |
Correct |
264 ms |
2308 KB |
Output is correct |
17 |
Correct |
264 ms |
2540 KB |
Output is correct |
18 |
Correct |
284 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
2384 KB |
Output is correct |
2 |
Correct |
270 ms |
2604 KB |
Output is correct |
3 |
Correct |
269 ms |
2244 KB |
Output is correct |
4 |
Correct |
263 ms |
2388 KB |
Output is correct |
5 |
Correct |
256 ms |
2248 KB |
Output is correct |
6 |
Correct |
248 ms |
2384 KB |
Output is correct |
7 |
Correct |
268 ms |
2504 KB |
Output is correct |
8 |
Correct |
277 ms |
2384 KB |
Output is correct |
9 |
Correct |
324 ms |
2384 KB |
Output is correct |
10 |
Correct |
291 ms |
2384 KB |
Output is correct |
11 |
Correct |
273 ms |
2384 KB |
Output is correct |
12 |
Correct |
263 ms |
2412 KB |
Output is correct |
13 |
Correct |
275 ms |
2636 KB |
Output is correct |
14 |
Correct |
266 ms |
2312 KB |
Output is correct |
15 |
Correct |
266 ms |
2588 KB |
Output is correct |
16 |
Correct |
264 ms |
2308 KB |
Output is correct |
17 |
Correct |
264 ms |
2540 KB |
Output is correct |
18 |
Correct |
284 ms |
2384 KB |
Output is correct |
19 |
Execution timed out |
7069 ms |
4644 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
2384 KB |
Output is correct |
2 |
Correct |
270 ms |
2604 KB |
Output is correct |
3 |
Correct |
269 ms |
2244 KB |
Output is correct |
4 |
Correct |
263 ms |
2388 KB |
Output is correct |
5 |
Correct |
256 ms |
2248 KB |
Output is correct |
6 |
Correct |
248 ms |
2384 KB |
Output is correct |
7 |
Correct |
268 ms |
2504 KB |
Output is correct |
8 |
Correct |
277 ms |
2384 KB |
Output is correct |
9 |
Correct |
324 ms |
2384 KB |
Output is correct |
10 |
Correct |
291 ms |
2384 KB |
Output is correct |
11 |
Correct |
273 ms |
2384 KB |
Output is correct |
12 |
Correct |
263 ms |
2412 KB |
Output is correct |
13 |
Correct |
275 ms |
2636 KB |
Output is correct |
14 |
Correct |
266 ms |
2312 KB |
Output is correct |
15 |
Correct |
266 ms |
2588 KB |
Output is correct |
16 |
Correct |
264 ms |
2308 KB |
Output is correct |
17 |
Correct |
264 ms |
2540 KB |
Output is correct |
18 |
Correct |
284 ms |
2384 KB |
Output is correct |
19 |
Correct |
293 ms |
2384 KB |
Output is correct |
20 |
Correct |
317 ms |
2228 KB |
Output is correct |
21 |
Correct |
287 ms |
2508 KB |
Output is correct |
22 |
Correct |
281 ms |
2284 KB |
Output is correct |
23 |
Correct |
307 ms |
2488 KB |
Output is correct |
24 |
Correct |
305 ms |
2392 KB |
Output is correct |
25 |
Correct |
296 ms |
2492 KB |
Output is correct |
26 |
Correct |
289 ms |
2228 KB |
Output is correct |
27 |
Correct |
289 ms |
2424 KB |
Output is correct |
28 |
Correct |
252 ms |
2132 KB |
Output is correct |
29 |
Correct |
279 ms |
2408 KB |
Output is correct |
30 |
Correct |
245 ms |
2408 KB |
Output is correct |
31 |
Correct |
304 ms |
2492 KB |
Output is correct |
32 |
Correct |
264 ms |
2384 KB |
Output is correct |
33 |
Correct |
275 ms |
2384 KB |
Output is correct |
34 |
Correct |
254 ms |
2256 KB |
Output is correct |
35 |
Correct |
274 ms |
2384 KB |
Output is correct |
36 |
Correct |
279 ms |
2384 KB |
Output is correct |
37 |
Correct |
278 ms |
2388 KB |
Output is correct |
38 |
Correct |
273 ms |
2388 KB |
Output is correct |
39 |
Correct |
274 ms |
2396 KB |
Output is correct |
40 |
Correct |
267 ms |
2372 KB |
Output is correct |
41 |
Correct |
280 ms |
2384 KB |
Output is correct |
42 |
Correct |
298 ms |
2384 KB |
Output is correct |
43 |
Correct |
258 ms |
2384 KB |
Output is correct |
44 |
Correct |
277 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
2384 KB |
Output is correct |
2 |
Correct |
270 ms |
2604 KB |
Output is correct |
3 |
Correct |
269 ms |
2244 KB |
Output is correct |
4 |
Correct |
263 ms |
2388 KB |
Output is correct |
5 |
Correct |
256 ms |
2248 KB |
Output is correct |
6 |
Correct |
248 ms |
2384 KB |
Output is correct |
7 |
Correct |
268 ms |
2504 KB |
Output is correct |
8 |
Correct |
277 ms |
2384 KB |
Output is correct |
9 |
Correct |
324 ms |
2384 KB |
Output is correct |
10 |
Correct |
291 ms |
2384 KB |
Output is correct |
11 |
Correct |
273 ms |
2384 KB |
Output is correct |
12 |
Correct |
263 ms |
2412 KB |
Output is correct |
13 |
Correct |
275 ms |
2636 KB |
Output is correct |
14 |
Correct |
266 ms |
2312 KB |
Output is correct |
15 |
Correct |
266 ms |
2588 KB |
Output is correct |
16 |
Correct |
264 ms |
2308 KB |
Output is correct |
17 |
Correct |
264 ms |
2540 KB |
Output is correct |
18 |
Correct |
284 ms |
2384 KB |
Output is correct |
19 |
Execution timed out |
7069 ms |
4644 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |