# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419974 | davi_bart | Crossing (JOI21_crossing) | C++14 | 59 ms | 760 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N,Q;
set<string> k;
string a,b,c;
string t;
vector<bool> ok;
void solve(){
if(k.count(t))cout<<"YES\n";
else cout<<"NO\n";
}
string cross(string x,string y){
string ans="";
vector<char> s={'I','J','O'};
for(int i=0;i<x.size();i++){
if(x[i]==y[i])ans+=x[i];
else{
for(auto h:s)if(x[i]!=h && y[i]!=h)ans+=h;
}
}
return ans;
}
void calc(){
while(1){
bool ok=0;
for(auto x:k){
for(auto y:k){
string h=cross(x,y);
if(k.count(h))continue;
ok=1;
k.insert(h);
}
}
if(!ok)break;
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);
cin>>N>>a>>b>>c>>Q>>t;
k.insert(a);k.insert(b);k.insert(c);
calc();
assert(k.size()<10);
solve();
for(int i=0;i<Q;i++){
int x,y;
char z;
cin>>x>>y>>z;
x--;y--;
for(int j=x;j<=y;j++)t[j]=z;
solve();
}
}
Compilation message (stderr)
# | 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... |