Submission #795906

# Submission time Handle Problem Language Result Execution time Memory
795906 2023-07-27T21:35:43 Z rainboy 토마토 (3차원) (KOI13_tomato3D) C
6 / 20
101 ms 13872 KB
#include <stdio.h>

#define N1	100
#define N2	100
#define N3	100

int max(int a, int b) { return a > b ? a : b; }

int main() {
	static int aa[N1][N2][N3], dd[N1][N2][N3], qu[N1 * N2 * N3];
	int n1, n2, n3, cnt, h, i1, i2, i3, u, d, d_;

	scanf("%d%d%d", &n2, &n3, &n1);
	for (i1 = 0; i1 < n1; i1++)
		for (i2 = 0; i2 < n2; i2++)
			for (i3 = 0; i3 < n3; i3++)
				scanf("%d", &aa[i1][i2][i3]);
	cnt = 0;
	for (i1 = 0; i1 < n1; i1++)
		for (i2 = 0; i2 < n2; i2++)
			for (i3 = 0; i3 < n3; i3++)
				if (aa[i1][i2][i3] == 1)
					dd[i1][i2][i3] = 0, qu[cnt++] = (i1 * n2 + i2) * n3 + i3;
				else
					dd[i1][i2][i3] = n1 * n2 * n3;
	for (h = 0; h < cnt; h++) {
		u = qu[h], i1 = u / n3 / n2, i2 = u / n3 % n2, i3 = u % n3, d = dd[i1][i2][i3] + 1;
		if (i1 > 0 && aa[i1 - 1][i2][i3] != -1 && dd[i1 - 1][i2][i3] > d)
			dd[i1 - 1][i2][i3] = d, qu[cnt++] = ((i1 - 1) * n2 + i2) * n3 + i3;
		if (i1 + 1 < n1 && aa[i1 + 1][i2][i3] != -1 && dd[i1 + 1][i2][i3] > d)
			dd[i1 + 1][i2][i3] = d, qu[cnt++] = ((i1 + 1) * n2 + i2) * n3 + i3;
		if (i2 > 0 && aa[i1][i2 - 1][i3] != -1 && dd[i1][i2 - 1][i3] > d)
			dd[i1][i2 - 1][i3] = d, qu[cnt++] = (i1 * n2 + (i2 - 1)) * n3 + i3;
		if (i2 + 1 < n2 && aa[i1][i2 + 1][i3] != -1 && dd[i1][i2 + 1][i3] > d)
			dd[i1][i2 + 1][i3] = d, qu[cnt++] = (i1 * n2 + (i2 + 1)) * n3 + i3;
		if (i3 > 0 && aa[i1][i2][i3 - 1] != -1 && dd[i1][i2][i3 - 1] > d)
			dd[i1][i2][i3 - 1] = d, qu[cnt++] = (i1 * n2 + i2) * n3 + (i3 - 1);
		if (i3 + 1 < n3 && aa[i1][i2][i3 + 1] != -1 && dd[i1][i2][i3 + 1] > d)
			dd[i1][i2][i3 + 1] = d, qu[cnt++] = (i1 * n2 + i2) * n3 + (i3 + 1);
	}
	d_ = 0;
	for (i1 = 0; i1 < n1; i1++)
		for (i2 = 0; i2 < n2; i2++)
			for (i3 = 0; i3 < n3; i3++)
				if (aa[i1][i2][i3] == 0)
					d_ = max(d_, dd[i1][i2][i3]);
	printf("%d\n", d_ == n1 * n2 * n3 ? -1 : d_);
	return 0;
}

Compilation message

cc.c: In function 'main':
cc.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d", &n2, &n3, &n1);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc.c:17:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &aa[i1][i2][i3]);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
3 Correct 2 ms 980 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 4644 KB Output is correct
2 Correct 14 ms 3748 KB Output is correct
3 Correct 21 ms 4888 KB Output is correct
4 Correct 7 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 8960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 8884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 82 ms 13404 KB Output is correct
2 Correct 76 ms 11948 KB Output is correct
3 Correct 101 ms 12088 KB Output is correct
4 Correct 84 ms 11772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 13872 KB Output is correct
2 Incorrect 33 ms 6708 KB Output isn't correct
3 Halted 0 ms 0 KB -