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