#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);
assert(st.size() < 10);
//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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
848 KB |
Output is correct |
2 |
Correct |
260 ms |
852 KB |
Output is correct |
3 |
Correct |
270 ms |
788 KB |
Output is correct |
4 |
Correct |
270 ms |
852 KB |
Output is correct |
5 |
Correct |
247 ms |
744 KB |
Output is correct |
6 |
Correct |
244 ms |
744 KB |
Output is correct |
7 |
Correct |
252 ms |
848 KB |
Output is correct |
8 |
Correct |
263 ms |
848 KB |
Output is correct |
9 |
Correct |
315 ms |
848 KB |
Output is correct |
10 |
Correct |
258 ms |
848 KB |
Output is correct |
11 |
Correct |
264 ms |
852 KB |
Output is correct |
12 |
Correct |
271 ms |
1044 KB |
Output is correct |
13 |
Correct |
267 ms |
848 KB |
Output is correct |
14 |
Correct |
279 ms |
892 KB |
Output is correct |
15 |
Correct |
256 ms |
980 KB |
Output is correct |
16 |
Correct |
264 ms |
964 KB |
Output is correct |
17 |
Correct |
260 ms |
852 KB |
Output is correct |
18 |
Correct |
282 ms |
1212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
848 KB |
Output is correct |
2 |
Correct |
260 ms |
852 KB |
Output is correct |
3 |
Correct |
270 ms |
788 KB |
Output is correct |
4 |
Correct |
270 ms |
852 KB |
Output is correct |
5 |
Correct |
247 ms |
744 KB |
Output is correct |
6 |
Correct |
244 ms |
744 KB |
Output is correct |
7 |
Correct |
252 ms |
848 KB |
Output is correct |
8 |
Correct |
263 ms |
848 KB |
Output is correct |
9 |
Correct |
315 ms |
848 KB |
Output is correct |
10 |
Correct |
258 ms |
848 KB |
Output is correct |
11 |
Correct |
264 ms |
852 KB |
Output is correct |
12 |
Correct |
271 ms |
1044 KB |
Output is correct |
13 |
Correct |
267 ms |
848 KB |
Output is correct |
14 |
Correct |
279 ms |
892 KB |
Output is correct |
15 |
Correct |
256 ms |
980 KB |
Output is correct |
16 |
Correct |
264 ms |
964 KB |
Output is correct |
17 |
Correct |
260 ms |
852 KB |
Output is correct |
18 |
Correct |
282 ms |
1212 KB |
Output is correct |
19 |
Execution timed out |
7065 ms |
2060 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
848 KB |
Output is correct |
2 |
Correct |
260 ms |
852 KB |
Output is correct |
3 |
Correct |
270 ms |
788 KB |
Output is correct |
4 |
Correct |
270 ms |
852 KB |
Output is correct |
5 |
Correct |
247 ms |
744 KB |
Output is correct |
6 |
Correct |
244 ms |
744 KB |
Output is correct |
7 |
Correct |
252 ms |
848 KB |
Output is correct |
8 |
Correct |
263 ms |
848 KB |
Output is correct |
9 |
Correct |
315 ms |
848 KB |
Output is correct |
10 |
Correct |
258 ms |
848 KB |
Output is correct |
11 |
Correct |
264 ms |
852 KB |
Output is correct |
12 |
Correct |
271 ms |
1044 KB |
Output is correct |
13 |
Correct |
267 ms |
848 KB |
Output is correct |
14 |
Correct |
279 ms |
892 KB |
Output is correct |
15 |
Correct |
256 ms |
980 KB |
Output is correct |
16 |
Correct |
264 ms |
964 KB |
Output is correct |
17 |
Correct |
260 ms |
852 KB |
Output is correct |
18 |
Correct |
282 ms |
1212 KB |
Output is correct |
19 |
Correct |
248 ms |
848 KB |
Output is correct |
20 |
Correct |
268 ms |
828 KB |
Output is correct |
21 |
Correct |
272 ms |
940 KB |
Output is correct |
22 |
Correct |
258 ms |
848 KB |
Output is correct |
23 |
Correct |
258 ms |
952 KB |
Output is correct |
24 |
Correct |
256 ms |
852 KB |
Output is correct |
25 |
Correct |
260 ms |
852 KB |
Output is correct |
26 |
Correct |
254 ms |
772 KB |
Output is correct |
27 |
Correct |
266 ms |
968 KB |
Output is correct |
28 |
Correct |
237 ms |
848 KB |
Output is correct |
29 |
Correct |
283 ms |
852 KB |
Output is correct |
30 |
Correct |
242 ms |
736 KB |
Output is correct |
31 |
Correct |
296 ms |
976 KB |
Output is correct |
32 |
Correct |
258 ms |
852 KB |
Output is correct |
33 |
Correct |
273 ms |
988 KB |
Output is correct |
34 |
Correct |
249 ms |
852 KB |
Output is correct |
35 |
Correct |
258 ms |
848 KB |
Output is correct |
36 |
Correct |
265 ms |
848 KB |
Output is correct |
37 |
Correct |
260 ms |
1052 KB |
Output is correct |
38 |
Correct |
270 ms |
852 KB |
Output is correct |
39 |
Correct |
272 ms |
852 KB |
Output is correct |
40 |
Correct |
288 ms |
792 KB |
Output is correct |
41 |
Correct |
270 ms |
1004 KB |
Output is correct |
42 |
Correct |
261 ms |
852 KB |
Output is correct |
43 |
Correct |
259 ms |
852 KB |
Output is correct |
44 |
Correct |
318 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
848 KB |
Output is correct |
2 |
Correct |
260 ms |
852 KB |
Output is correct |
3 |
Correct |
270 ms |
788 KB |
Output is correct |
4 |
Correct |
270 ms |
852 KB |
Output is correct |
5 |
Correct |
247 ms |
744 KB |
Output is correct |
6 |
Correct |
244 ms |
744 KB |
Output is correct |
7 |
Correct |
252 ms |
848 KB |
Output is correct |
8 |
Correct |
263 ms |
848 KB |
Output is correct |
9 |
Correct |
315 ms |
848 KB |
Output is correct |
10 |
Correct |
258 ms |
848 KB |
Output is correct |
11 |
Correct |
264 ms |
852 KB |
Output is correct |
12 |
Correct |
271 ms |
1044 KB |
Output is correct |
13 |
Correct |
267 ms |
848 KB |
Output is correct |
14 |
Correct |
279 ms |
892 KB |
Output is correct |
15 |
Correct |
256 ms |
980 KB |
Output is correct |
16 |
Correct |
264 ms |
964 KB |
Output is correct |
17 |
Correct |
260 ms |
852 KB |
Output is correct |
18 |
Correct |
282 ms |
1212 KB |
Output is correct |
19 |
Execution timed out |
7065 ms |
2060 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |