# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580796 | HeyYouNotYouYou | Igra (COCI17_igra) | C++14 | 1 ms | 212 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 int long long
#define endl '\n'
using namespace std;
const int N = 30,INF=1e12;
string a,b;
int n;
int32_t main()
{
//freopen("abc.in", "r", stdin);
cin>>n;
cin>>a>>b;
int aa=0,bb=0,cc=0,aaa=0,bbb=0,ccc=0;
string ans="";
for(int i = 0 ; i < a.size() ; i++)
{
if(a[i]=='a') aa++;
else if(a[i]=='b') bb++;
else cc++;
if(b[i]=='a') aaa++;
else if(b[i]=='b') bbb++;
else ccc++;
}
for(int i = 0 ; i < n ; i ++){
if(b[i]=='a' && (bb-1+aa)>=(ccc)) ans+='b',aaa--,bb--;
else if(b[i]=='a') ans+='c',aaa--,cc--;
else if(b[i]=='c' && (aa-1+cc)>=(bbb)) ans+='a',ccc--,aa--;
else if(b[i]=='c') ans+='b',ccc--,bb--;
else if(b[i]=='b' && (aa-1+bb)>=(ccc)) ans+='a',bbb--,aa--;
else if(b[i]=='b') ans+='c',bbb--,cc--;
}
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |