Submission #503302

#TimeUsernameProblemLanguageResultExecution timeMemory
503302rainboyLampice (COCI21_lampice)C11
50 / 50
1 ms276 KiB
#include <stdio.h> #include <string.h> #define N 50 int max(int a, int b) { return a > b ? a : b; } void zzz(int *aa, int *zz, int n) { int i, l, r; memset(zz, 0, n * sizeof *zz); for (i = 1, l = 0, r = 0; i < n; i++) if (i + zz[i - l] < r) zz[i] = zz[i - l]; else { l = i, r = max(r, i); while (r < n && aa[r] == aa[r - l]) r++; zz[i] = r - l; } } int main() { static int aa[N], zz[N]; int n, k, h, i, j; scanf("%d%d", &n, &k); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = 0; i < n; i++) { zzz(aa + i, zz, n - i); for (j = i + 1; j < n; j++) if (zz[j - i] >= (j - i) * (k - 1)) { printf("%d\n", j - i); for (h = i; h < j; h++) printf("%d ", aa[h]); printf("\n"); return 0; } } printf("-1\n"); return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:27:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:29:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...