Submission #11764

#TimeUsernameProblemLanguageResultExecution timeMemory
11764gs12117Three Friends (BOI14_friends)C++98
100 / 100
16 ms4996 KiB
#include<stdio.h> int n; char a[2001000]; char b[2001000]; int main(){ int i,t,flag; scanf("%d",&n); scanf("%s",a); if(n%2==0){ puts("NOT POSSIBLE"); return 0; } for(i=0;i<n/2;i++){ if(a[i]!=a[i+n/2])break; } t=i; for(i=n/2-1;i>=0;i--){ if(a[i]!=a[i+n/2+1])break; } if(t>i)flag=1; else flag=0; for(i=0;i<n/2+1;i++){ if(a[i]!=a[i+n/2+1])break; } t=i; for(i=n/2;i>=0;i--){ if(a[i]!=a[i+n/2])break; } if(t>=i){ if(flag==1){ for(i=0;i<n/2;i++){ if(a[i]!=a[i+n/2+1])break; } if(i==n/2){ for(i=0;i<n/2;i++){ b[i]=a[i]; } puts(b); } else{ puts("NOT UNIQUE"); } } else{ for(i=0;i<n/2;i++){ b[i]=a[i+n/2+1]; } puts(b); } } else{ if(flag==1){ for(i=0;i<n/2;i++){ b[i]=a[i]; } puts(b); } else{ puts("NOT POSSIBLE"); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...