#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define ar array
#define ld long double
#define int long long
#define all(v) v.begin(), v.end()
const int N = 2e5 + 20;
const int K = 469;
const int LOG = 26;
const int INF = 1e12;
int MOD = 998244353;
bool qry(string s, string t){
while(s.size() && s.back() == t.back())s.pop_back(), t.pop_back();
if(s.size())t.pop_back();
while(s.size() && s.back() == t.back())s.pop_back(), t.pop_back();
return s.empty();
}
void orz(){
int n;
string s;
cin>>n>>s;
if(n % 2 == 0){
cout<<"NOT POSSIBLE";
return;
}
bool x = qry(s.substr(0, n / 2), s.substr(n / 2, n / 2 + 1));
bool y = qry(s.substr(n / 2 + 1, n / 2), s.substr(0, n / 2 + 1));
if(!x && !y){
cout<<"NOT POSSIBLE";
return;
}
if(x && y && s.substr(0, n / 2) != s.substr(n / 2 + 1, n / 2)){
cout<<"NOT UNIQUE";
return;
}
if(y)cout<<s.substr(n / 2 + 1, n / 2);
else cout<<s.substr(0, n / 2);
}
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
int t;
//cin>>t;
t = 1;
while(t--)orz();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |