# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100746 | dalgerok | Igra (COCI17_igra) | C++17 | 3 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int cnt1[3], cnt2[3];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
string s, t;
cin >> s >> t;
for(int i = 0; i < n; i++){
cnt1[s[i] - 'a'] += 1;
cnt2[t[i] - 'a'] += 1;
}
for(int i = 0; i < n; i++){
cnt2[t[i] - 'a'] -= 1;
for(int j = 0; j < 3; j++){
if(t[i] - 'a' != j){
if(j == 0 && cnt1[0]){
if(cnt1[0] - 1 + cnt1[1] >= cnt2[2] && cnt1[0] - 1 + cnt1[2] >= cnt2[1]){
cout << 'a';
cnt1[0] -= 1;
break;
}
}
if(j == 1 && cnt1[1]){
if(cnt1[1] - 1 + cnt1[2] >= cnt2[0] && cnt1[1] - 1 + cnt1[0] >= cnt2[2]){
cout << 'b';
cnt1[1] -= 1;
break;
}
}
if(j == 2 & cnt1[2]){
if(cnt1[2] - 1 + cnt1[1] >= cnt2[0] && cnt1[2] - 1 + cnt1[0] >= cnt2[1]){
cout << 'c';
cnt1[2] -= 1;
break;
}
}
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |