# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499097 |
2021-12-27T08:38:21 Z |
LouayFarah |
Igra (COCI17_igra) |
C++14 |
|
1 ms |
332 KB |
#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 |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |