#include<bits/stdc++.h>
using namespace std;
#ifndef BADGNU
#pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=2e5+100;
const int M=5001;
const int B=447;
const int mod=998244353;
const ll INF=1e18;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const char pidr[]={'X','J','O','I'};
const double eps=1e-6;
string operator^(const string&x,const string&y){
string res=x;
for(int i=0;i<res.size();i++){
if(res[i]==y[i])continue;
res[i]^=y[i];
}
return res;
}
int which(char x){
if(x=='J')return 1;
if(x=='O')return 2;
if(x=='I')return 3;
return 0;
}
void compess(string&x){
for(auto &i:x){
i=which(i);
}
}
int n;
string s[3];
int q;
string t0;
void test(){
cin>>n;
vector<string>v;
for(int i=0;i<=2;i++){
cin>>s[i];
compess(s[i]);
v.push_back(s[i]);
}
while(1ll){
int cur=v.size();
for(int i=0;i<cur;i++){
for(int j=i+1;j<cur;j++){
v.push_back(v[i]^v[j]);
}
}
sort(v.begin(),v.end());
v.resize(unique(v.begin(),v.end())-v.begin());
if(v.size()==cur)break;
}
cin>>q;
cin>>t0;
compess(t0);
{
bool ok=0;
for(auto j:v){
if(j==t0){
ok=1;
break;
}
}
if(ok){
cout<<"Yes\n";
}
else{
cout<<"No\n";
}
}
for(int l,r;q--;){
char c;
cin>>l>>r>>c;
l--;
r--;
c=which(c);
for(int j=l;j<=r;j++){
t0[j]=c;
}
bool ok=0;
for(auto j:v){
if(j==t0){
ok=1;
break;
}
}
if(ok){
cout<<"Yes\n";
}
else{
cout<<"No\n";
}
}
}
/*
*/
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
int t2=1;
// cin>>t2;
for(int i=1;i<=t2;i++){
test();
}
}
# | 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... |