Submission #10706

#TimeUsernameProblemLanguageResultExecution timeMemory
10706dohyun0324Three Friends (BOI14_friends)C++98
100 / 100
32 ms18664 KiB
#include<stdio.h> int dap,cnt,p,n,arr1[2000010],arr2[2000010],s1,s2; char a[2000010]; int main() { int i; scanf("%d",&n); scanf("%s",a); if(n%2==0){printf("NOT POSSIBLE"); return 0;} for(i=0;i<=n/2;i++) { if(a[i]==a[i+n/2]) arr1[i]=1; if(a[i]==a[i+n/2+1]) arr2[i]=1; } for(i=n/2;i>=0;i--) if(arr1[i]!=1) break; s1=n/2-i; for(i=0;i<=n/2;i++) if(arr2[i]!=1) break; s2=i; if(s1+s2==n/2) dap=s2, cnt++; if(s1+s2>n/2) { int sw=0; for(i=s2;i>=0;i--) { if(n/2-i>s1) break; if(a[i]!=a[s2]) sw=1; } if(sw==1){printf("NOT UNIQUE"); return 0;} dap=s2; cnt++; } if(dap==n/2) cnt=0; for(i=0;i<n/2;i++) if(arr1[i]!=1) break; s1=i; for(i=n/2-1;i>=0;i--) if(arr2[i]!=1) break; s2=n/2-1-i; if(s1+s2>=n/2) { if(cnt){printf("NOT UNIQUE"); return 0;} else{ dap=n/2; cnt++;} } if(cnt) { for(i=0;i<=n/2;i++) { if(i!=dap) printf("%c",a[i]); } } else printf("NOT POSSIBLE"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...