이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |