답안 #930745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930745 2024-02-20T11:08:55 Z Pwo 세 명의 친구들 (BOI14_friends) C++17
0 / 100
36 ms 6052 KB
#include <bits/stdc++.h>
using namespace std;

int32_t main() {
    int n; cin >> n; string s; cin >> s;
    if (n % 2 == 0) { cout << "NOT POSSIBLE"; return 0; }
    
    int mp1[26]{}, mp2[26]{}; int l = (n - 1) / 2;
    for (int i = 0; i < n; i++) {
        int chr = (s[i] - 'A');
        if (i < l) mp1[chr]++;
        else mp2[chr]++;
    }
    int d1 = 0; for (int i = 0; i < 26; i++) d1 += abs(mp1[i] - mp2[i]);
    
    fill(mp1, mp1 + 26, 0); fill(mp2, mp2 + 26, 0); l = (n + 1) / 2;
    for (int i = 0; i < n; i++) {
        int chr = (s[i] - 'A');
        if (i < l) mp1[chr]++;
        else mp2[chr]++;
    }
    int d2 = 0; for (int i = 0; i < 26; i++) d2 += abs(mp1[i] - mp2[i]);

    if (d1 == 1 && d2 == 1) cout << "NOT UNIQUE";
    else if (d1 == 1) cout << s.substr(0, (n - 1) / 2);
    else if (d2 == 1) cout << s.substr((n + 1) / 2, (n - 1) / 2);
    else cout << "NOT POSSIBLE";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 5836 KB Output is correct
2 Correct 33 ms 4280 KB Output is correct
3 Correct 31 ms 4376 KB Output is correct
4 Correct 32 ms 4428 KB Output is correct
5 Correct 31 ms 4300 KB Output is correct
6 Correct 27 ms 4944 KB Output is correct
7 Incorrect 36 ms 6052 KB Output isn't correct
8 Halted 0 ms 0 KB -