This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
if(n%2==0||n<3){
cout << "NOT POSSIBLE";
return 0;
}
string s;
cin >> s;
set<string> ans;
string a="",b="";
int mid=n/2;
for(int i=mid+1; i<n; i++) a+=s[i];
int p1,p2;
for(p1=0; p1<mid; p1++){
if(s[p1]!=a[p1]) break;
}
for(p2=mid; p2>0; p2--){
if(s[p2]!=a[p2-1]) break;
}
if(p1>=p2) ans.insert(a);
for(int i=0; i<mid; i++) b+=s[i];
for(p1=mid; p1<n-1; p1++){
if(s[p1]!=b[p1-mid]) break;
}
for(p2=n-1; p2>mid; p2--){
if(s[p2]!=b[p2-1-mid]) break;
}
if(p1>=p2) ans.insert(b);
if(ans.size()>1) cout << "NOT UNIQUE";
else if(ans.size()==1) cout << *ans.begin();
else cout << "NOT POSSIBLE";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |