# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
477388 | largefence | Igra (COCI17_igra) | C++17 | 1 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int cnt[3], mp[5243][4];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
//freopen("ws.INP", "r", stdin);
//freopen("ws.OUT", "w", stdout);
memset(cnt, 0, sizeof cnt);
memset(mp, 0, sizeof mp);
int n; cin >> n;
string a, b; cin >> a >> b;
for (int i = n - 1; i >= 0; i--) {
cnt[a[i] - 'a']++;
for (int j = 0; j < 3; j++)
mp[i][j] = mp[i + 1][j] + ((b[i] - 'a') == j);
} string res = "";
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
if (!cnt[j] || (b[i] - 'a') == j) continue;
bool chk = true;
for (int k = 0; k < 3 && chk; k++) {
int tmp = 0;
for (int k2 = 0; k2 < 3; k2++)
if (k != k2) tmp += cnt[k2] - (k2 == j);
if (mp[i + 1][k] > tmp) chk = false;
}
if (chk) {
res += (j + 'a');
cnt[j]--;
}
}
} cout << res;
return 0;
}
/* In case of emergency,
___ _____ _____ _ _ ___
/ __|_ _\ \ / / __| | | | | _ \
| (_ || | \ V /| _| | |_| | _/
\___|___| \_/ |___| \___/|_|
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |