제출 #16777

#제출 시각아이디문제언어결과실행 시간메모리
16777kdh9949세 명의 친구들 (BOI14_friends)C++98
100 / 100
27 ms3144 KiB
#include<stdio.h> #include<string.h> char a[2111111]; int n,p,q; int f(int pivots,int pivote,int targets,int targete) { int j=pivots,i=targets,k=0; for(;i<=targete;i++) { if(a[i]==a[j])j++,k++; } return (k>=n/2); } int main() { scanf("%d%s",&n,a); if(n%2==0) { puts("NOT POSSIBLE"); return 0; } p=f(0,n/2-1,n/2,n-1); q=f(n/2+1,n-1,0,n/2); a[n/2]=0; if(p&&q) { if(strcmp(a,a+n/2+1))puts("NOT UNIQUE"); else puts(a); } else if(p&&(!q)) puts(a); else if((!p)&&q) puts(a+n/2+1); else puts("NOT POSSIBLE"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...