Submission #620016

#TimeUsernameProblemLanguageResultExecution timeMemory
620016APROHACKCrossing (JOI21_crossing)C++14
26 / 100
7049 ms5656 KiB
#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(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...