# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
620014 | APROHACK | Crossing (JOI21_crossing) | C++14 | 299 ms | 2188 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>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll n, q;
string a, b, c, x;
vector<string>strings;
set<string>st;
void input(){
cin>>n;
cin>>a>>b>>c;
strings.pb(a);
strings.pb(b);
strings.pb(c);
st.insert(a);
st.insert(b);
st.insert(c);
}
bool join(int a, int b){
string nueva="";
cout << a << " " << b << endl;
for(int i = 0 ; i < n ; i++){
if(strings[a][i]==strings[b][i]){
nueva+=strings[a][i];
}else {
if(strings[a][i]=='J' && strings[b][i]=='O' || strings[b][i]=='J' && strings[a][i]=='O')nueva+="I";
else if(strings[a][i]=='I' && strings[b][i]=='O' || strings[b][i]=='I' && strings[a][i]=='O')nueva+="J";
else if(strings[a][i]=='I' && strings[b][i]=='J' || strings[b][i]=='I' && strings[a][i]=='J')nueva+="O";
}
}
if(st.find(nueva)==st.end()){
//cout << nueva << endl;
st.insert(nueva);
strings.pb(nueva);
}else{
return false;
}
return true;
}
void calculateString(){
bool ans = true;
while(ans){
ans = false;
int gen = strings.size();
for(int i = 0 ; i < gen-1; i++){
for(int j = i+1 ; j < gen ; j++){
if(join(i, j))ans = true;
}
}
}
}
void querys(){
cin>>q;
cin>>x;
if(st.find(x)!=st.end())cout<<"Yes\n";
else cout << "No\n";
int l, r;
char c;
for(int i = 0 ;i < q ; i++){
cin>>l>>r>>c;
for(int i = l-1 ; i <= r-1 ; i++){
x[i]=c;
}
//cout << "ask "<<x<<endl;
if(st.find(x)!=st.end())cout<<"Yes\n";
else cout << "No\n";
}
}
int main(){
input();
calculateString();
querys();
}
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... |