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 n;
string a,x,ox,y,oy;
int main()
{
cin>>n>>a;
if(n%2==0)
{
cout<<"NOT POSSIBLE";
return 0;
}
for(int i=0;i<n/2;i++)x.push_back(a[i]);
for(int i=(n/2)+1;i<n;i++)y.push_back(a[i]);
ox=x;
oy=y;
x+=x;
y+=y;
int cnt=0,aa=0,bb=0;
for(int i=0,j=0;i<n;i++)
{
if(a[i]==x[j])j++;
else cnt++;
if(cnt>1)break;
if(i==n-1)aa++;
}
cnt=0;
for(int i=0,j=0;i<n;i++)
{
if(a[i]==y[j])j++;
else cnt++;
if(cnt>1)break;
if(i==n-1)bb++;
}
if(aa+bb==0)
{
cout<<"NOT POSSIBLE";
return 0;
}
if(aa+bb==2&&ox!=oy)
{
cout<<"NOT UNIQUE";
return 0;
}
if(aa)cout<<ox;
else if(bb)cout<<oy;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |