Submission #944503

#TimeUsernameProblemLanguageResultExecution timeMemory
944503rainboy입력숫자 (KOI13_mystery)C11
100 / 100
1 ms748 KiB
#include <stdio.h> #include <string.h> #define N 30 int n; int ds[N], rr[N]; char marked[N]; int find(int i) { return ds[i] < 0 ? i : (ds[i] = find(ds[i])); } void join(int i, int j) { i = find(i); j = find(j); if (i == j) return; if (ds[i] > ds[j]) ds[i] = j; else { if (ds[i] == ds[j]) ds[i]--; ds[j] = i, rr[i] = rr[j]; } } int next(int i) { return !marked[i] ? i : (rr[find(i)] + 1) % n; } void mark(int i) { marked[i] = 1; if (marked[(i - 1 + n) % n]) join((i - 1 + n) % n, i); if (marked[(i + 1) % n]) join(i, (i + 1) % n); } int main() { static int aa[N]; int h, i; scanf("%d", &n); memset(ds, -1, n * sizeof *ds); for (i = 0; i < n; i++) rr[i] = i; i = 0; for (h = 0; h < n; h++) { i = next(i); scanf("%d", &aa[i]); mark(i); i = (i + aa[i]) % n; } printf("%d\n", n); for (i = 0; i < n; i++) printf("%d ", aa[i]); printf("\n"); return 0; }

Compilation message (stderr)

mystery.c: In function 'main':
mystery.c:44:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
mystery.c:51:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   scanf("%d", &aa[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...