# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550106 | ToroTN | Three Friends (BOI14_friends) | C++14 | 49 ms | 5248 KiB |
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,m,l,r,cnt,st,ed,krit;
char s[2000005];
int main()
{
scanf("%d",&n);
scanf("%s",s+1);
m=n/2;
if(n%2==0)
{
printf("NOT POSSIBLE\n");
return 0;
}
l=1;
r=m+1;
cnt=0;
while(l<=m&&r<=n)
{
if(s[l]==s[r])
{
++l,++r;
}else
{
++r;
++cnt;
}
}
if(cnt<=1)
{
st=1;
}
l=1;
r=m+2;
cnt=0;
while(l<=m+1&&r<=n)
{
if(s[l]==s[r])
{
++l,++r;
}else
{
++l;
++cnt;
}
}
if(cnt<=1)
{
ed=1;
}
if(st==1&&ed==1)
{
krit=0;
for(int i=1;i<=m;i++)
{
if(s[i]==s[i+m+1])++krit;
}
if(krit==m)
{
for(int i=1;i<=m;i++)
{
printf("%c",s[i]);
}
printf("\n");
}else
{
printf("NOT UNIQUE\n");
}
}else if(st==1)
{
for(int i=1;i<=m;i++)
{
printf("%c",s[i]);
}
printf("\n");
}else if(ed==1)
{
for(int i=m+2;i<=n;i++)
{
printf("%c",s[i]);
}
printf("\n");
}else
{
printf("NOT POSSIBLE\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |