# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41125 | 14kg | Three Friends (BOI14_friends) | C++11 | 75 ms | 19636 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 <stdio.h>
#define N 2000005
int n, link[N];
char in[N];
int main(){
int scnt=0, out=0, len=0;
scanf("%d %s",&n,in+1);
if(n%2==0){ printf("NOT POSSIBLE"); return 0; }
for(int i=2; i<=n/2+1; i++){
int j=n/2+i;
scnt+=(in[i]==in[j]);
link[i]=j, link[j]=i;
}
if(scnt==n/2) out=1;
for(int i=2; i<=n; i++){
int x=i-1, y=link[i];
scnt-=(in[i]==in[y]);
link[x]=y, link[y]=x;
scnt+=(in[x]==in[y]);
if(scnt==n/2 && out){
if(out==i-1 && in[i-1]==in[i]) out++;
else{ printf("NOT UNIQUE"); return 0; }
}
else if(scnt==n/2) out=i;
}
if(!out){ printf("NOT POSSIBLE"); return 0; }
for(int i=1; len<n/2; i++){
if(i==out) continue;
len++, printf("%c",in[i]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |