Submission #544612

#TimeUsernameProblemLanguageResultExecution timeMemory
544612rainboyThree Friends (BOI14_friends)C11
100 / 100
11 ms5136 KiB
#include <stdio.h> #include <string.h> #define N 2000001 int solve(char *aa, char *bb, int n) { int i; i = 0; while (i < n && aa[i] == bb[i]) i++; i++; while (i <= n && aa[i] == bb[i - 1]) i++; return i > n; } int main() { static char cc[N + 1]; int n, pref, suff; scanf("%d%s", &n, cc); if (n % 2 == 0) { printf("NOT POSSIBLE\n"); return 0; } pref = solve(cc + n / 2, cc, n / 2); suff = solve(cc, cc + n / 2 + 1, n / 2); if (!pref && !suff) printf("NOT POSSIBLE\n"); else if (pref && suff) printf("%s\n", strncmp(cc, cc + n / 2 + 1, n / 2) != 0 ? "NOT UNIQUE" : cc + n / 2 + 1); else if (pref) { cc[n / 2] = 0; printf("%s\n", cc); } else printf("%s\n", cc + n / 2 + 1); return 0; }

Compilation message (stderr)

friends.c: In function 'main':
friends.c:22:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%s", &n, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...