# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170597 |
2019-12-25T17:56:13 Z |
mdn2002 |
Igra (COCI17_igra) |
C++14 |
|
2 ms |
376 KB |
#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |