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;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
map<string, int> vis;
queue<string> q;
string ini[3];
string spoj(string a, string b){
string ret = a;
for(int i = 0; i < (int)a.size(); i++){
if(a[i] == b[i]) ret[i] = a[i];
else ret[i] = 'J' + 'I' + 'O' - a[i] - b[i];
}
return ret;
}
void bfs(){
while(!q.empty()){
string sega = q.front();
q.pop();
for(int i = 0; i < 3; i++){
string spoeno = spoj(sega, ini[i]);
if(!vis[spoeno]){
vis[spoeno] = 1;
q.push(spoeno);
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n>>ini[0]>>ini[1]>>ini[2];
for(int i = 0; i < 3; i++){
q.push(ini[i]);
vis[ini[i]] = 1;
}
bfs();
int q;
cin>>q;
string str;
cin>>str;
if(vis[str]) cout<<"Yes\n";
else cout<<"No\n";
while(q--){
int l, r;
char c;
cin>>l>>r>>c;
l--; r--;
for(int i = l; i <= r; i++) str[i] = c;
if(vis[str]) cout<<"Yes\n";
else cout<<"No\n";
}
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... |