답안 #477388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477388 2021-10-02T01:19:16 Z largefence Igra (COCI17_igra) C++17
20 / 100
1 ms 336 KB
#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 /| _|  | |_| |  _/
  \___|___| \_/ |___|  \___/|_|

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 0 ms 336 KB Output isn't correct
5 Incorrect 1 ms 336 KB Output isn't correct
6 Incorrect 1 ms 336 KB Output isn't correct
7 Incorrect 1 ms 336 KB Output isn't correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Incorrect 1 ms 336 KB Output isn't correct
10 Incorrect 1 ms 336 KB Output isn't correct