제출 #1357855

#제출 시각아이디문제언어결과실행 시간메모리
1357855kutomei3Three Friends (BOI14_friends)C++20
0 / 100
1094 ms8216 KiB
#include <bits/stdc++.h>
using namespace std;

string ans = "NOT POSSIBLE";
bool check(string &s, int pos, int n)
{
    string ns;
    for (int i = 0; i < n; i++) {
        if (i != pos) ns += s[i];
    }
    bool c = true;
    for (int i = 0; i < n / 2; i++) {
        if (ns[i] != ns[i + n / 2]) c = false; 
    }
    if (c) {
        string t;
        for (int i = 0; i < n / 2; i++) {
            t += ns[i];
        }
        ans = t;
    }
    return c;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    string s;
    cin >> s;

    if (!(n & 1)) {
        cout << "NOT POSSIBLE";
        return 0;
    }

    int sl = n / 2;
    int ct = 0;
    for (int i = 0; i < n; i++) {
        if (check(s, i, n)) ct++;
    }

    if (ct >= 2) cout << "NOT UNIQUE";
    else cout << ans;

    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…