# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170597 | mdn2002 | Igra (COCI17_igra) | C++14 | 2 ms | 376 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>
using namespace std;
const long long mod=998244353;
int n,c[4],d[4];
string a,b;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("lemonade.in","r",stdin);
//freopen("lemonade.out","w",stdout);
cin>>n>>a>>b;
for(int i=0; i<n; i++)c[a[i]-'a']++;
for(int i=0; i<n; i++)d[b[i]-'a']++;
for(int i=0; i<n; i++)
{
d[b[i]-'a']--;
for(int j=0; j<3; j++)
{
if(b[i]-'a'==j)continue;
if(j==0&&c[0])
{
if(c[1]+c[2]>=d[0]&&c[0]+c[2]-1>=d[1]&&c[0]+c[1]-1>=d[2])
{
cout<<'a';
c[0]--;
break;
}
}
if(j==1&&c[1])
{
if(c[1]+c[2]-1>=d[0]&&c[0]+c[2]>=d[1]&&c[0]+c[1]-1>=d[2])
{
cout<<'b';
c[1]--;
break;
}
}
if(j==2&&c[2])
{
if(c[1]+c[2]-1>=d[0]&&c[0]+c[2]-1>=d[1]&&c[0]+c[1]>=d[2])
{
cout<<'c';
c[2]--;
break;
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |