Submission #472978

#TimeUsernameProblemLanguageResultExecution timeMemory
472978rainboySpirale (COCI18_spirale)C11
80 / 80
48 ms312 KiB
#include <stdio.h> #define N 50 #define M 50 #define INF 0x3f3f3f3f int min(int a, int b) { return a < b ? a : b; } int solve(int i, int j) { if (i == 0 && j == 0) return 1; if (i < j && j <= -i) return (-i * 2 - 1) * (-i * 2 - 1) + j - i; if (-j < i && i <= j) return (j * 2 - 1) * (j * 2 - 1) + j * 2 + i + j; if (-i < -j && -j <= i) return (i * 2 - 1) * (i * 2 - 1) + i * 4 - j + i; if (j < -i && -i <= -j) return (-j * 2 - 1) * (-j * 2 - 1) + -j * 6 - i - j; return -1; } int main() { static int ii[N * M], jj[N * M], tt[N * M]; int n, m, k, h, i, j; scanf("%d%d%d", &n, &m, &k); for (h = 0; h < k; h++) scanf("%d%d%d", &ii[h], &jj[h], &tt[h]); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { int a = INF; for (h = 0; h < k; h++) a = min(a, solve(i - ii[h], tt[h] == 0 ? j - jj[h] : jj[h] - j)); printf("%d ", a); } printf("\n"); } return 0; }

Compilation message (stderr)

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