Submission #112585

#TimeUsernameProblemLanguageResultExecution timeMemory
112585ioilolcomIgra (COCI17_igra)C++14
20 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; int pi[4],u[4]; bool check(){ return (u[1]+u[2]>=pi[0])&&(u[2]+u[0]>=pi[1])&&(u[1]+u[0]>=pi[2]); } int main() { ios_base:: sync_with_stdio(false); cin.tie(0); int n; cin>>n; string a,b; string ans=""; cin>>a>>b; for(int i=0; i<n; i++) { u[a[i]-'a']++; pi[b[i]-'a']++; } // //string ans=""; // how can i know if a solution exist if i take a char a //cout<<u[0]<<" "<<u[1]<<" "<<u[2]<<endl; for(int i=0; i<n; i++) { for(int j=0; j<3; j++) { if(j!=b[i]-'a') { if(u[j]) { u[j]--; pi[b[i]-'a']--; if(!check()) { u[j]++; pi[a[i]-'a']++; continue; } ans+=(char)(j+'a'); break; } } } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...