This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*input
3
JOI
JOI
JOI
2
OJI
1 2 O
1 1 J
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("Ofast")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (ll)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e17;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
return (a*b)%MOD;
}
ll mypow(ll a,ll b){
ll res=1;
while(b){
if(b&1) res=mult(res,a);
a=mult(a,a);
b/=2;
}
return res;
}
string arr[3];
string bl="JOI";
string op(string a,string b){
string ans="";
REP(i,sz(a)){
if(a[i]==b[i]) ans.pb(a[i]);
else{
REP(k,3){
if(bl[k]!=a[i] and bl[k]!=b[i]) ans.pb(bl[k]);
}
}
}
return ans;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int n;
cin>>n;
REP(i,3) cin>>arr[i];
vector<string> v;
REP(i,3){
v.pb(arr[i]);
REP(j,i){
v.pb(op(arr[i],arr[j]));
}
}
vector<int> b;
REP(i,3) b.pb(i);
do{
string cur="";
for(auto x:b){
if(!sz(cur)) cur=arr[x];
else cur=op(cur,arr[x]);
}
v.pb(cur);
}while(next_permutation(ALL(b)));
int q;
cin>>q;
string s;
cin>>s;
bool hv=0;
for(auto x:v){
if(x==s){
cout<<"Yes\n";
hv=1;
break;
}
}
if(!hv) cout<<"No\n";
while(q--){
int l,r;
char c;
cin>>l>>r>>c;
--l,--r;
for(int i=l;i<=r;i++) s[i]=c;
bool hv=0;
for(auto x:v){
if(x==s){
cout<<"Yes\n";
hv=1;
break;
}
}
if(!hv) cout<<"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... |