제출 #14813

#제출 시각아이디문제언어결과실행 시간메모리
14813eaststar세 명의 친구들 (BOI14_friends)C++98
100 / 100
25 ms3036 KiB
#include <stdio.h> #include <string.h> char a[2000010]; int f(int s1,int e1,int s2,int e2){ int cnt=0; while(s1<=e1){ if(a[s1]==a[s2])++s1,++s2; else{ if(cnt)return 0; ++s2,++cnt; } } return 1; } int main() { int i,n,flag=0; scanf("%d",&n); if(n%2==0){ puts("NOT POSSIBLE"); return 0; } scanf("%s",a+1); if(!strncmp(a+n/2+2,a+1,n/2)){ for(i=1;i<=n/2;++i)printf("%c",a[i]); return 0; } if(f(1,n/2,n/2+1,n))flag=1; if(f(n/2+2,n,1,n/2+1)){ if(flag){ puts("NOT UNIQUE"); return 0; } flag=2; } if(!flag)puts("NOT POSSIBLE"); if(flag==1)for(i=1;i<=n/2;++i)printf("%c",a[i]); if(flag==2)for(i=n/2+2;i<=n;++i)printf("%c",a[i]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...