This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |