#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int pi[4],u[4];
bool check(){
return (u[1]+u[2]>=pi[0])&&(u[2]+u[0]>=pi[1])&&(u[1]+u[0]>=pi[2]);
}
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
string a,b;
string ans="";
cin>>a>>b;
for(int i=0; i<n; i++) {
u[a[i]-'a']++;
pi[b[i]-'a']++;
}
//
//string ans="";
// how can i know if a solution exist if i take a char a
//cout<<u[0]<<" "<<u[1]<<" "<<u[2]<<endl;
for(int i=0; i<n; i++) {
for(int j=0; j<3; j++) {
if(j!=b[i]-'a') {
if(u[j]) {
u[j]--;
pi[b[i]-'a']--;
if(!check()) {
u[j]++; pi[a[i]-'a']++;
continue;
}
ans+=(char)(j+'a');
break;
}
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |