# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
476177 |
2021-09-25T07:53:34 Z |
KDisabledA |
Igra (COCI17_igra) |
C++14 |
|
1 ms |
204 KB |
#include <bits/stdc++.h>
using namespace std;
const int N=5e3+10;
string s,t;
int cnt[2][5];
int n;
bool ok(){
bool kq=1;
for(int i=0;i<3;++i)kq&=(cnt[0][i]>=0);
kq&=(cnt[0][0]<=cnt[1][1]+cnt[1][2]);
kq&=(cnt[0][1]<=cnt[1][0]+cnt[1][2]);
kq&=(cnt[0][2]<=cnt[1][0]+cnt[1][1]);
return kq;
}
signed main(){
cin>>n>>s>>t;
//cout<<s<<' '<<t<<endl;
for(int i=0;i<n;++i){
cnt[0][s[i]-'a']++;
cnt[1][t[i]-'a']++;
}
string ans="";
for(int i=0;i<n;++i){
cnt[1][t[i]-'a']--;
for(int j=0;j<3;++j){
if(j!=t[i]-'a'){
cnt[0][j]--;
if(ok()){
ans+=(char)('a'+j);
break;
}
++cnt[0][j];
}
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |