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<stdio.h>
#include<string.h>
char a[2111111];
int n,p,q;
int f(int pivots,int pivote,int targets,int targete)
{
int j=pivots,i=targets,k=0;
for(;i<=targete;i++)
{
if(a[i]==a[j])j++,k++;
}
return (k>=n/2);
}
int main()
{
scanf("%d%s",&n,a);
if(n%2==0)
{
puts("NOT POSSIBLE");
return 0;
}
p=f(0,n/2-1,n/2,n-1);
q=f(n/2+1,n-1,0,n/2);
a[n/2]=0;
if(p&&q)
{
if(strcmp(a,a+n/2+1))puts("NOT UNIQUE");
else puts(a);
}
else if(p&&(!q)) puts(a);
else if((!p)&&q) puts(a+n/2+1);
else puts("NOT POSSIBLE");
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |