#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 30,INF=1e12;
string a,b;
int n;
int32_t main()
{
//freopen("abc.in", "r", stdin);
cin>>n;
cin>>a>>b;
int aa=0,bb=0,cc=0,aaa=0,bbb=0,ccc=0;
string ans="";
for(int i = 0 ; i < a.size() ; i++)
{
if(a[i]=='a') aa++;
else if(a[i]=='b') bb++;
else cc++;
if(b[i]=='a') aaa++;
else if(b[i]=='b') bbb++;
else ccc++;
}
for(int i = 0 ; i < n ; i ++){
if(b[i]=='a' && (bb-1+aa)>=(ccc) && (bb-1+cc)>=(aaa-1) && bb) ans+='b',aaa--,bb--;
else if(b[i]=='a') ans+='c',aaa--,cc--;
else if(b[i]=='c' && (aa-1+cc)>=(bbb) && (aa-1+bb)>=(ccc-1) && aa) ans+='a',ccc--,aa--;
else if(b[i]=='c') ans+='b',ccc--,bb--;
else if(b[i]=='b' && (aa-1+bb)>=(ccc) && (aa-1+cc)>=(bbb-1) && aa) ans+='a',bbb--,aa--;
else if(b[i]=='b') ans+='c',bbb--,cc--;
}
cout<<ans;
}
Compilation message
igra.cpp: In function 'int32_t main()':
igra.cpp:15:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i = 0 ; i < a.size() ; i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |