#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
bool check(string s,string t) {
int j = 0;
for (int i = 0; i < s.size() && j < t.size();i++) {
if (s[i] == t[j]) j++;
}
return j == t.size();
}
void solve() {
int n;
cin >> n;
string s;
cin >> s;
if (n % 2 == 0) {
cout << "NOT POSSIBLE";
return;
}
int m = n / 2;
string a = s.substr(0,m), b = s.substr(0,m + 1), c = s.substr(m + 1),d = s.substr(m);
if (check(d,a)) {
if (check(b,c)) {
if (a != c) cout << "NOT UNIQUE";
else cout << a;
}else cout <<a;
}else {
if (check(b,c)) {
cout << c;
}else cout << "NOT POSSIBLE";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
cout << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |