Submission #10693

#TimeUsernameProblemLanguageResultExecution timeMemory
10693baneling100Three Friends (BOI14_friends)C++98
100 / 100
16 ms3040 KiB
#include <stdio.h> #include <vector> using namespace std; int N, Size, Left[3], Right[3]; char S[2000005]; void Check(int L1, int R1, int L2, int R2) { int i, j, Num, Cnt=0; for(i=L1, j=L2 ; i<=R1 && j<=R2 ; i++, j++) { if(S[i]!=S[j]) { Num=i; Cnt++; j--; } if(Cnt>1) return; } if(!Cnt) Num=R1; Size++; Left[Size]=L2; Right[Size]=R2; } int Same(void) { int i, j; for(i=Left[1], j=Left[2] ; i<=Right[1] && j<=Right[2] ; i++, j++) if(S[i]!=S[j]) return 0; return 1; } int main(void) { int mid; scanf("%d %s",&N,&S[1]); if(!(N%2)) { printf("NOT POSSIBLE"); return 0; } mid=(N+1)/2; Check(1,mid,mid+1,N); Check(mid,N,1,mid-1); if(Size==0) printf("NOT POSSIBLE"); else if(Size==1 || (Size==2 && Same())) { S[Right[1]+1]=NULL; printf("%s",&S[Left[1]]); } else printf("NOT UNIQUE"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...