#include <bits/stdc++.h>
using namespace std;
#define cin(vec) for(auto& i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b) for (int i = a; i < b; i++)
#define F first
#define S second
#define pb(n) push_back(n)
#define pf(n) push_front(n)
#define mp make_pair
#define dci(d) fixed<<setprecision(d)
#define sp ' '
#define el '\n'
#define all(v) v.begin(),v.end()
#define int long long
int dx[8]= {0,0,1,-1,-1,1,1,-1};
int dy[8]= {-1,1,0,0,-1,1,-1,1};
int const N=2e5+5,M=1e3+1,Mod=1e9+7;
int a1,b1,c1,a2,b2,c2,n;
void testcase(int h){
string s1,s2;cin>>n>>s1>>s2;
for(int i=0;i<n;i++){
if(s1[i]=='a')a1++;
if(s1[i]=='b')b1++;
if(s1[i]=='c')c1++;
}
for(int i=0;i<n;i++){
if(s2[i]=='a')a2++;
if(s2[i]=='b')b2++;
if(s2[i]=='c')c2++;
}
for(int i=0;i<n;i++){
if(s2[i]=='a'){
a2--;
if(b1){
b1--;
if((b1+c1>=a2&&b1+a1>=c2)||!c1){
cout<<'b';
continue;
}
b1++;
}
c1--;
cout<<'c';
}
if(s2[i]=='b'){
b2--;
if(a1){
a1--;
if((a1+b1>=c2&&a1+c1>=b2)||!c1){
cout<<'a';
continue;
}
a1++;
}
c1--;
cout<<'c';
}
if(s2[i]=='c'){
c2--;
if(a1){
a1--;
if((a1+c1>=b2&&b1+a1>=c2)||!b1){
cout<<'a';
continue;
}
a1++;
}
b1--;
cout<<'b';
}
}
}
int32_t main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// fast
testcase(1);
// int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
284 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |