Submission #620014

#TimeUsernameProblemLanguageResultExecution timeMemory
620014APROHACKCrossing (JOI21_crossing)C++14
0 / 100
299 ms2188 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(); }

Compilation message (stderr)

Main.cpp: In function 'bool join(int, int)':
Main.cpp:28:35: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   28 |             if(strings[a][i]=='J' && strings[b][i]=='O' || strings[b][i]=='J' && strings[a][i]=='O')nueva+="I";
Main.cpp:29:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   29 |             else if(strings[a][i]=='I' && strings[b][i]=='O' || strings[b][i]=='I' && strings[a][i]=='O')nueva+="J";
Main.cpp:30:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   30 |             else if(strings[a][i]=='I' && strings[b][i]=='J' || strings[b][i]=='I' && strings[a][i]=='J')nueva+="O";
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...