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;
int main(){
int n;
cin>>n;
vector<string> v(3);
cin>>v[0]>>v[1]>>v[2];
auto cross = [&](string a,string b){
string s;
for(int i=0;i<n;i++){
if(a[i]==b[i]) s+=a[i];
else{
for(auto c:"JOI")
if(c!=a[i]&&c!=b[i]){
s+=c;
break;
}
}
}
return s;
};
set<string> s(v.begin(),v.end());
while(true){
bool f=false;
set<string> ss=s;
for(auto x:s){
for(auto y:s){
string t=cross(x,y);
if(s.count(t)) continue;
ss.insert(t);f=true;
}
}
s=ss;
if(!f) break;
}
int q;
cin>>q;
string t;
cin>>t;
puts(s.count(t)?"Yes":"No");
while(q--){
int l,r;
cin>>l>>r;
l--,r--;
char c;
cin>>c;
for(int i=l;i<=r;i++) t[i]=c;
puts(s.count(t)?"Yes":"No");
}
}
# | 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... |