Submission #10704

#TimeUsernameProblemLanguageResultExecution timeMemory
10704dohyun0324Three Friends (BOI14_friends)C++98
0 / 100
24 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); 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(dap==n/2) cnt=0; if(s1+s2>n/2){ printf("NOT UNIQUE"); return 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(s1+s2>n/2){printf("NOT UNIQUE"); return 0;} 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...