# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40987 | XmtosX | Igra (COCI17_igra) | C++14 | 3 ms | 696 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;
int n,a[200],b[200];
string s1,s2,s;
bool check ()
{
for (int i=0;i<=b['a'];i++)
{
int x= (a['b']-i);
int y= (a['c']-(b['a']-i));
if (x<0||y<0)
continue;
if (x>b['c']||y>b['b'])
continue;
return 1;
}
return 0;
}
int main()
{
cin >>n>>s1>>s2;
for (int i=0;i<n;i++)
a[s1[i]]++,b[s2[i]]++;
for (int i=0;i<n;i++)
{
b[s2[i]]--;
for (int j='a';j<='c';j++)
{
if (j==s2[i]||!a[j])
continue;
a[j]--;
if (check())
{
s+=j;
break;
}
a[j]++;
}
}
cout <<s;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |