#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |