제출 #1143740

#제출 시각아이디문제언어결과실행 시간메모리
1143740Rainmaker2627세 명의 친구들 (BOI14_friends)C++20
0 / 100
19 ms6208 KiB
#include<bits/stdc++.h>
using namespace std;

int n;
string s;
bool test(string a) {
    int i=0, j=0;
    for (; i < n; i++) {
        if (j==n-1) break; 
        if (s[i]==a[j]) j++;
    } return i-j<2;
}

int main() {
    cin.tie(0)->sync_with_stdio(false);

    cin >> n >> s;
    if (n%2==0) { cout << "NOT POSSIBLE"; return 0; }
    bool first=test(s.substr(0, n/2)+s.substr(0, n/2));
    bool second=test(s.substr(n/2+1)+s.substr(n/2+1));
    if (first && second) cout << "NOT UNIQUE";
    else if (first) cout << s.substr(0, n/2);
    else if (second) cout << s.substr(n/2+1);
    else cout << "NOT POSSIBLE";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...