# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127515 | TadijaSebez | Three Friends (BOI14_friends) | C++11 | 60 ms | 5240 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;
#define pb push_back
const int N=2000050;
char s[N];
int main()
{
int n,A=0,B=0,C=0,D=0;
scanf("%i",&n);
scanf("%s",s+1);
if(n%2==0) return 0*printf("NOT POSSIBLE\n");
int x=(n+1)/2,y=x+1,z=x-1;
while(s[A+1]==s[A+x]) A++;
while(s[B+1]==s[B+y]) B++;
while(s[n-C]==s[x-C]) C++;
while(s[n-D]==s[z-D]) D++;
//printf("%i %i %i %i\n",A,B,C,D);
vector<int> ans;
int hal=n/2;
if(B>=hal)
{
ans.pb(x);
}
else
{
if(B+C>=hal) ans.pb(1);
if(A+D>=hal) ans.pb(n);
/*for(int i=1;i<x;i++)
{
if(B>=i-1 && C>=x-i){ ans.pb(i);break;}
}
for(int i=x+1;i<=n;i++)
{
if(A>=i-x && D>=n-i){ ans.pb(i);break;}
}*/
}
if(ans.empty()) printf("NOT POSSIBLE\n");
else if(ans.size()>1) printf("NOT UNIQUE\n");
else
{
//printf("%i\n",ans[0]);
if(ans[0]<=x) for(int i=x+1;i<=n;i++) printf("%c",s[i]);
else for(int i=1;i<x;i++) printf("%c",s[i]);
printf("\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |