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 n;
string inp[3];
string t;
set<string> valid;
int order[3]={0,1,2};
void check()
{
if(valid.count(t))cout<<"Yes\n";
else cout<<"No\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
for(int i=0;i<3;i++)cin>>inp[i];
do
{
string cur="";
for(int i=0;i<=5;i++)
{
if(i==0)cur=inp[order[i]];
else
{
int other=order[i%3];
for(int k=0;k<n;k++)
{
if(cur[k]!=inp[other][k])
{
cur[k]=1LL*'I'+'J'+'O'-cur[k]-inp[other][k];
}
}
}
valid.insert(cur);
}
}
while(next_permutation(order,order+3));
int q;
cin>>q;
cin>>t;
check();
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;
check();
}
return 0;
}
# | 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... |