# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499097 | LouayFarah | Igra (COCI17_igra) | C++14 | 1 ms | 332 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;
#define endl "\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const long long MOD = 1e9+7;
const long long INF = 1e18;
int nx[4] = {0, 0, -1, 1};
int ny[4] = {1, -1, 0, 0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
string x, y;
cin >> x >> y;
ll a = 0, b = 0, c = 0;
ll A = 0, B = 0, C = 0;
for(int i = 0; i<n; i++)
{
if(x[i]=='a')
a++;
if(x[i]=='b')
b++;
if(x[i]=='c')
c++;
}
for(int i = 0; i<n; i++)
{
if(y[i]=='a')
A++;
if(y[i]=='b')
B++;
if(y[i]=='c')
C++;
}
string res = "";
for(int i = 0; i<n; i++)
{
char ch = y[i];
if(ch=='a')
{
if(a+b<=C||b==0)
{
res.pb('c');
c--;
}
else
{
res.pb('b');
b--;
}
A--;
}
if(ch=='b')
{
if(a+b<=C||a==0)
{
res.pb('c');
c--;
}
else
{
res.pb('a');
a--;
}
B--;
}
if(ch=='c')
{
if(a+c<=B||a==0)
{
res.pb('b');
b--;
}
else
{
res.pb('a');
a--;
}
C--;
}
}
cout << res << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |