# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87818 | Koschei | Igra (COCI17_igra) | C++17 | 3 ms | 744 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 <iostream>
using namespace std;
const int MAXN = 5001;
int n;
int cnts[3];
int cntm[3];
char s[MAXN];
char m[MAXN];
char r[3] = {'a', 'b', 'c'};
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> s >> m;
for (int i = 0; i < n; i++)
{
cnts[s[i]-'a']++;
cntm[m[i]-'a']++;
}
for (int i = 0; i < n; i++)
{
cntm[m[i]-'a']--;
for (int j = 0; j < 3; j++)
{
if (m[i] != r[j])
{
if ((j == 0) && cnts[0])
{
if ((cnts[0]+cnts[1]>=cntm[2]+1) && (cnts[0]+cnts[2]>=cntm[1]+1))
{
cout << 'a';
cnts[0]--;
break;
}
}
if ((j == 1) && cnts[1])
{
if ((cnts[0]+cnts[1]>=cntm[2]+1) && (cnts[1]+cnts[2]>=cntm[0]+1))
{
cout << 'b';
cnts[1]--;
break;
}
}
if ((j == 2) && cnts[2])
{
if ((cnts[2]+cnts[1]>=cntm[0]+1) && (cnts[0]+cnts[2]>=cntm[1]+1))
{
cout << 'c';
cnts[2]--;
break;
}
}
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |