This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//IN THE NAME OF GOD
#include<bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#define endl '\n'
#define F first
#define S second
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double dll;
vector<string> vec;
string merge(string a, string b){
string make = "";
for(int i=0; i<int(a.size()); i++){
if (a[i] == b[i]) make += a[i];
else{
if ((a[i] == 'O' && b[i] == 'J') || (a[i] == 'J' && b[i] == 'O')) make+='I';
if ((a[i] == 'O' && b[i] == 'I') || (a[i] == 'I' && b[i] == 'O')) make+='J';
if ((a[i] == 'I' && b[i] == 'J') || (a[i] == 'J' && b[i] == 'I')) make+='O';
}
}
return make;
}
int32_t main(){
fastio;
int n; cin >> n;
string a,b,c; cin >> a >> b >> c;
vec.pb(a);
vec.pb(b);
vec.pb(c);
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
if (i == j) continue;
vec.pb(merge(vec[i],vec[j]));
}
}
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
if (i == j) continue;
for(int k =0; k<3; k++){
if (k == i || k == j) continue;
vec.pb(merge(merge(vec[i],vec[j]),vec[k]));
}
}
}
int q; cin >> q;
string t; cin >> t;
bool ans = false;
for(string cur : vec) if (cur == t) ans = true;
cout << (ans ? "Yes" : "No") << endl;
while(q--){
int l,r; cin >> l >> r; l--; r--;
char c; cin >> c;
for(int i=l;i<=r; i++) t[i] = c;
bool ans = false;
for(string cur : vec) if (cur == t) ans = true;
cout << (ans ? "Yes" : "No") << endl;
}
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... |