Submission #545466

#TimeUsernameProblemLanguageResultExecution timeMemory
545466rainboySpace Pirate (JOI14_space_pirate)C11
10 / 100
2083 ms2388 KiB
#include <stdio.h> #include <string.h> #define N 100000 int solve(int *pp, int n, long long k) { static int tt[N]; int i, t; memset(tt, 0, n * sizeof *tt); i = 0, t = 0; while (!tt[i]) tt[i] = t++, i = pp[i]; k = (k - t) % (t - tt[i]); while (k--) i = pp[i]; return i; } int main() { static int pp[N]; static long long ans[N]; int n, i; long long k; scanf("%d%lld", &n, &k); for (i = 0; i < n; i++) scanf("%d", &pp[i]), pp[i]--; for (i = 0; i < n; i++) { int p = pp[i]; for (pp[i] = 0; pp[i] < n; pp[i]++) ans[solve(pp, n, k)]++; pp[i] = p; } for (i = 0; i < n; i++) printf("%lld\n", ans[i]); return 0; }

Compilation message (stderr)

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