Submission #40395

#TimeUsernameProblemLanguageResultExecution timeMemory
40395szawinisSpirale (COCI18_spirale)C++14
80 / 80
86 ms788 KiB
#include <bits/stdc++.h> using namespace std; int n, m, k, f[51][51]; int dx[4] = {-1, 0, 1, 0}, dy[2][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}}; int main() { scanf("%d %d %d", &n, &m, &k); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) f[i][j] = 1e9; for(int z = 0, x, y, t; z < k; z++) { scanf("%d %d %d", &x, &y, &t); f[x][y] = 1; int elapsed = 1; for(int i = 1; i <= 200; i++) for(int j = 0; j < i+1 >> 1; j++) { ++elapsed; x += dx[(i-1) % 4]; y += dy[t][(i-1) % 4]; if(x >= 1 && x <= n && y >= 1 && y <= m) f[x][y] = min(elapsed, f[x][y]); } } for(int i = 1; i <= n; i++, printf("\n")) for(int j = 1; j <= m; j++) printf("%d ", f[i][j]); }

Compilation message (stderr)

spirale.cpp: In function 'int main()':
spirale.cpp:13:53: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   for(int i = 1; i <= 200; i++) for(int j = 0; j < i+1 >> 1; j++) {
                                                     ^
spirale.cpp:7:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
                               ^
spirale.cpp:10:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &t);
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...