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;
int main(){
int m;cin>>m;
if((m%2==0)||(m==1)){
cout<<"NOT POSSIBLE";
return 0;
}
int n=m/2;
string a;
cin>>a;
string fa=a.substr(0,n);
string fb=a.substr(n);
string sa=a.substr(0,n+1);
string sb=a.substr(n+1);
// cout<<fa<<" "<<fb<<endl<<sa<<" "<<sb<<endl;
int vff,vfb;
int vsf,vsb;
for( vff=0 ; vff < n ; vff ++)
if(fa[vff]!=fb[vff])break;
for( vfb=0 ; vfb < n ; vfb ++)
if(fa[n-1-vfb]!=fb[n-vfb])break;
for( vsf=0 ; vsf < n ; vsf ++)
if(sa[vsf]!=sb[vsf])break;
for( vsb=0 ; vsb < n ; vsb ++)
if(sa[n-vsb]!=sb[n-1-vsb])break;
// cout<<vff<<" "<<vfb<<endl<<vsf<<" "<<vsb<<endl;
if(vfb==n||vsf==n){
if(vfb==n&&vff==0&&vsf==n&&vsb==0){
cout<<fa;
}else{
cout<<"NOT UNIQUE";
}
return 0;
}
int sf=vff+vfb;
int ss=vsf+vsb;
if(sf>n||ss>n||(sf==n&&ss==n)){
cout<<"NOT UNIQUE";
return 0;
}
if(sf<n&&ss<n){
cout<<"NOT POSSIBLE";
return 0;
}
if(sf==n){
cout<<fa;
}else if(ss==n){
cout<<sb;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |