| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 40395 | szawinis | Spirale (COCI18_spirale) | C++14 | 86 ms | 788 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
