# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051556 | happy_node | Crossing (JOI21_crossing) | C++17 | 7065 ms | 5948 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.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(time(0));
string JOI="JOI";
string merge(string a, string b) {
string c="";
for(int i=0;i<a.size();i++) {
if(a[i]==b[i]) c+=a[i];
else {
if(a[i]!='J' && b[i]!='J') c+='J';
if(a[i]!='O' && b[i]!='O') c+='O';
if(a[i]!='I' && b[i]!='I') c+='I';
}
}
return c;
}
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
int N;
cin>>N;
string sa, sb, sc;
cin>>sa>>sb>>sc;
vector<string> v;
set<string> st;
if(!st.count(sa)) {
v.push_back(sa);
st.insert(sa);
}
if(!st.count(sb)) {
v.push_back(sb);
st.insert(sb);
}
if(!st.count(sc)) {
v.push_back(sc);
st.insert(sc);
}
while(true) {
bool fnd=0;
for(int i=0;i<v.size();i++) {
for(int j=i+1;j<v.size();j++) {
string c=merge(v[i],v[j]);
if(!st.count(c)) {
fnd=true;
v.push_back(c);
st.insert(c);
}
}
}
if(!fnd) break;
}
int Q;
cin>>Q;
string S;
cin>>S;
cout<<(st.count(S)?"Yes":"No")<<'\n';
for(int i=0;i<Q;i++) {
int l,r; char c;
cin>>l>>r>>c;
l--,r--;
for(int j=l;j<=r;j++) S[j]=c;
cout<<(st.count(S)?"Yes":"No")<<'\n';
}
}
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... |