#include <iostream>
#include <string>
using namespace std;
using str = string*;
const int N = 101;
const int Q = 200'002;
int n, q;
string pos[9];
string t;
char add(char a, char b){
if(a==b) return a;
if(a=='I' and b=='O') return 'J';
if(a=='I' and b=='J') return 'O';
if(a=='J' and b=='O') return 'I';
if(a=='J' and b=='I') return 'O';
if(a=='O' and b=='I') return 'J';
if(a=='O' and b=='J') return 'I';
cerr << "help" << endl;
return 'x';
}
str combine(str a, str b){
str ans = new string;
for(int i=0; i<n; i++){
ans->push_back(add((*a)[i], (*b)[i]));
}
return ans;
}
bool check(str a){
for(int i=0; i<9; i++){
if(*a == pos[i]) return true;
}
return false;
}
void print(str a){
if(check(a)) cout << "Yes\n";
else cout << "No\n";
}
int main(){
cin >> n >> pos[0] >> pos[1] >> pos[2];
pos[3] = *combine(&pos[0], &pos[1]);
pos[4] = *combine(&pos[0], &pos[2]);
pos[5] = *combine(&pos[2], &pos[1]);
pos[6] = *combine(&pos[0], combine(&pos[2], &pos[1]));
pos[7] = *combine(&pos[1], combine(&pos[0], &pos[2]));
pos[8] = *combine(&pos[2], combine(&pos[0], &pos[1]));
cin >> q >> t;
print(&t);
for(int i=0; i<q; i++){
int l, r;
char c;
cin >> l >> r >> c;
for(int j=l-1; j<r; j++){
t[j] = c;
}
print(&t);
}
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... |