#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
string T = "JOI";
string get(string a, string b) {
string res;
for(int i = 0; i < n; i++)
if(a[i] == b[i]) res += a[i];
else {
int k = 0;
while(T[k] == a[i] || T[k] == b[i]) k++;
res += T[k];
}
return res;
}
vector<string> st;
bool check(string s) {
for(string cur : st)
if(cur == s) return 1;
return 0;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n;
string s[3];
cin >> s[0] >> s[1] >> s[2];
st.push_back(s[0]);
st.push_back(s[1]);
st.push_back(s[2]);
st.push_back(get(s[0], s[1]));
st.push_back(get(s[0], s[2]));
st.push_back(get(s[1], s[2]));
st.push_back(get(s[0], get(s[1], s[2])));
st.push_back(get(s[0], get(s[2], s[1])));
st.push_back(get(s[1], get(s[2], s[0])));
int q;
cin >> q;
string t;
cin >> t;
cout << (check(t) ? "Yes\n" : "No\n");
while(q--) {
int l, r; char x;
cin >> l >> r >> x;
for(int i = l - 1; i < r; i++)
t[i] = x;
cout << (check(t) ? "Yes\n" : "No\n");
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
844 KB |
Output is correct |
2 |
Correct |
81 ms |
844 KB |
Output is correct |
3 |
Correct |
89 ms |
904 KB |
Output is correct |
4 |
Correct |
79 ms |
784 KB |
Output is correct |
5 |
Correct |
85 ms |
928 KB |
Output is correct |
6 |
Correct |
78 ms |
792 KB |
Output is correct |
7 |
Correct |
82 ms |
844 KB |
Output is correct |
8 |
Correct |
82 ms |
832 KB |
Output is correct |
9 |
Correct |
82 ms |
904 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
11 |
Correct |
80 ms |
844 KB |
Output is correct |
12 |
Correct |
92 ms |
804 KB |
Output is correct |
13 |
Correct |
80 ms |
844 KB |
Output is correct |
14 |
Correct |
83 ms |
904 KB |
Output is correct |
15 |
Correct |
80 ms |
800 KB |
Output is correct |
16 |
Correct |
80 ms |
848 KB |
Output is correct |
17 |
Correct |
83 ms |
852 KB |
Output is correct |
18 |
Correct |
100 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
844 KB |
Output is correct |
2 |
Correct |
81 ms |
844 KB |
Output is correct |
3 |
Correct |
89 ms |
904 KB |
Output is correct |
4 |
Correct |
79 ms |
784 KB |
Output is correct |
5 |
Correct |
85 ms |
928 KB |
Output is correct |
6 |
Correct |
78 ms |
792 KB |
Output is correct |
7 |
Correct |
82 ms |
844 KB |
Output is correct |
8 |
Correct |
82 ms |
832 KB |
Output is correct |
9 |
Correct |
82 ms |
904 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
11 |
Correct |
80 ms |
844 KB |
Output is correct |
12 |
Correct |
92 ms |
804 KB |
Output is correct |
13 |
Correct |
80 ms |
844 KB |
Output is correct |
14 |
Correct |
83 ms |
904 KB |
Output is correct |
15 |
Correct |
80 ms |
800 KB |
Output is correct |
16 |
Correct |
80 ms |
848 KB |
Output is correct |
17 |
Correct |
83 ms |
852 KB |
Output is correct |
18 |
Correct |
100 ms |
896 KB |
Output is correct |
19 |
Execution timed out |
7063 ms |
4208 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
844 KB |
Output is correct |
2 |
Correct |
81 ms |
844 KB |
Output is correct |
3 |
Correct |
89 ms |
904 KB |
Output is correct |
4 |
Correct |
79 ms |
784 KB |
Output is correct |
5 |
Correct |
85 ms |
928 KB |
Output is correct |
6 |
Correct |
78 ms |
792 KB |
Output is correct |
7 |
Correct |
82 ms |
844 KB |
Output is correct |
8 |
Correct |
82 ms |
832 KB |
Output is correct |
9 |
Correct |
82 ms |
904 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
11 |
Correct |
80 ms |
844 KB |
Output is correct |
12 |
Correct |
92 ms |
804 KB |
Output is correct |
13 |
Correct |
80 ms |
844 KB |
Output is correct |
14 |
Correct |
83 ms |
904 KB |
Output is correct |
15 |
Correct |
80 ms |
800 KB |
Output is correct |
16 |
Correct |
80 ms |
848 KB |
Output is correct |
17 |
Correct |
83 ms |
852 KB |
Output is correct |
18 |
Correct |
100 ms |
896 KB |
Output is correct |
19 |
Correct |
82 ms |
812 KB |
Output is correct |
20 |
Correct |
91 ms |
904 KB |
Output is correct |
21 |
Correct |
82 ms |
804 KB |
Output is correct |
22 |
Correct |
77 ms |
860 KB |
Output is correct |
23 |
Correct |
88 ms |
872 KB |
Output is correct |
24 |
Correct |
80 ms |
804 KB |
Output is correct |
25 |
Correct |
126 ms |
900 KB |
Output is correct |
26 |
Correct |
79 ms |
848 KB |
Output is correct |
27 |
Correct |
80 ms |
816 KB |
Output is correct |
28 |
Correct |
81 ms |
776 KB |
Output is correct |
29 |
Correct |
82 ms |
872 KB |
Output is correct |
30 |
Correct |
99 ms |
844 KB |
Output is correct |
31 |
Incorrect |
82 ms |
844 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
844 KB |
Output is correct |
2 |
Correct |
81 ms |
844 KB |
Output is correct |
3 |
Correct |
89 ms |
904 KB |
Output is correct |
4 |
Correct |
79 ms |
784 KB |
Output is correct |
5 |
Correct |
85 ms |
928 KB |
Output is correct |
6 |
Correct |
78 ms |
792 KB |
Output is correct |
7 |
Correct |
82 ms |
844 KB |
Output is correct |
8 |
Correct |
82 ms |
832 KB |
Output is correct |
9 |
Correct |
82 ms |
904 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
11 |
Correct |
80 ms |
844 KB |
Output is correct |
12 |
Correct |
92 ms |
804 KB |
Output is correct |
13 |
Correct |
80 ms |
844 KB |
Output is correct |
14 |
Correct |
83 ms |
904 KB |
Output is correct |
15 |
Correct |
80 ms |
800 KB |
Output is correct |
16 |
Correct |
80 ms |
848 KB |
Output is correct |
17 |
Correct |
83 ms |
852 KB |
Output is correct |
18 |
Correct |
100 ms |
896 KB |
Output is correct |
19 |
Execution timed out |
7063 ms |
4208 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |