Submission #13346

#TimeUsernameProblemLanguageResultExecution timeMemory
13346woqja125Three Friends (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...