제출 #13346

#제출 시각아이디문제언어결과실행 시간메모리
13346woqja125세 명의 친구들 (BOI14_friends)C++98
100 / 100
26 ms3036 KiB
#include<stdio.h> char s[2000010]; int main() { int n, n2, cnt = 0, i; scanf("%d%s", &n, s); if(n%2 == 0) { printf("NOT POSSIBLE\n"); return 0; } n2 = n/2; int ch = 0; for(i=n2+1; i<n; i++) { if(ch == 0 && s[i-n2-1] == s[i]) continue; else if(ch == 0 && s[i-n2] == s[i]) ch++; else if (ch == 0) break; else if (ch == 1 && s[i-n2] != s[i]) break; } if(i==n) cnt++; ch = 0; for(i=0; i<n2; i++) { if(ch == 0 && s[i+n2] == s[i]) continue; else if(ch == 0 && s[i+n2+1] == s[i]) ch++; else if(ch == 0) break; else if(ch == 1 && s[i+n2+1] != s[i]) break; } if(i==n2) { if(cnt == 0) { for(i=0; i<n2; i++) printf("%c", s[i]); } else { for(i=0; i<n2; i++) if(s[i] != s[i+n2+1]) break; if(i==n2) for(i=0; i<n2; i++) printf("%c", s[i]); else printf("NOT UNIQUE\n"); } } else if(cnt == 1) { for(i=n2+1; i<n; i++)printf("%c", s[i]); } else printf("NOT POSSIBLE\n"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...