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>
int dap,cnt,p,n,arr1[2000010],arr2[2000010],s1,s2;
char a[2000010];
int main()
{
int i;
scanf("%d",&n);
scanf("%s",a);
if(n%2==0){printf("NOT POSSIBLE"); return 0;}
for(i=0;i<=n/2;i++)
{
if(a[i]==a[i+n/2]) arr1[i]=1;
if(a[i]==a[i+n/2+1]) arr2[i]=1;
}
for(i=n/2;i>=0;i--) if(arr1[i]!=1) break;
s1=n/2-i;
for(i=0;i<=n/2;i++) if(arr2[i]!=1) break;
s2=i;
if(s1+s2==n/2) dap=s2, cnt++;
if(s1+s2>n/2)
{
int sw=0;
for(i=s2;i>=0;i--)
{
if(n/2-i>s1) break;
if(a[i]!=a[s2]) sw=1;
}
if(sw==1){printf("NOT UNIQUE"); return 0;}
dap=s2; cnt++;
}
if(dap==n/2) cnt=0;
for(i=0;i<n/2;i++) if(arr1[i]!=1) break;
s1=i;
for(i=n/2-1;i>=0;i--) if(arr2[i]!=1) break;
s2=n/2-1-i;
if(s1+s2>=n/2)
{
if(cnt){printf("NOT UNIQUE"); return 0;}
else{ dap=n/2; cnt++;}
}
if(cnt)
{
for(i=0;i<=n/2;i++)
{
if(i!=dap) printf("%c",a[i]);
}
}
else printf("NOT POSSIBLE");
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |