結果
問題 | No.1572 XI |
ユーザー | 👑 ygussany |
提出日時 | 2021-06-27 13:54:12 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 2,302 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 71,552 KB |
最終ジャッジ日時 | 2024-06-25 11:31:28 |
合計ジャッジ時間 | 5,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 47 ms
19,456 KB |
testcase_05 | AC | 106 ms
36,992 KB |
testcase_06 | AC | 132 ms
48,896 KB |
testcase_07 | AC | 4 ms
5,376 KB |
testcase_08 | AC | 114 ms
42,368 KB |
testcase_09 | AC | 61 ms
36,608 KB |
testcase_10 | AC | 92 ms
41,984 KB |
testcase_11 | AC | 7 ms
5,376 KB |
testcase_12 | AC | 46 ms
29,952 KB |
testcase_13 | AC | 14 ms
12,032 KB |
testcase_14 | AC | 44 ms
24,192 KB |
testcase_15 | AC | 9 ms
5,632 KB |
testcase_16 | AC | 40 ms
25,728 KB |
testcase_17 | AC | 10 ms
12,544 KB |
testcase_18 | AC | 56 ms
32,128 KB |
testcase_19 | AC | 117 ms
45,312 KB |
testcase_20 | AC | 81 ms
38,528 KB |
testcase_21 | AC | 138 ms
48,256 KB |
testcase_22 | AC | 109 ms
41,344 KB |
testcase_23 | AC | 7 ms
7,936 KB |
testcase_24 | AC | 1 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 1 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 206 ms
66,432 KB |
testcase_35 | AC | 201 ms
66,560 KB |
testcase_36 | AC | 203 ms
67,200 KB |
testcase_37 | AC | 215 ms
69,504 KB |
testcase_38 | AC | 203 ms
67,968 KB |
testcase_39 | AC | 213 ms
68,480 KB |
testcase_40 | AC | 201 ms
63,872 KB |
testcase_41 | AC | 207 ms
66,944 KB |
testcase_42 | AC | 206 ms
68,224 KB |
testcase_43 | AC | 205 ms
67,712 KB |
testcase_44 | AC | 221 ms
71,552 KB |
testcase_45 | AC | 222 ms
71,552 KB |
testcase_46 | AC | 221 ms
71,424 KB |
testcase_47 | AC | 22 ms
26,496 KB |
testcase_48 | AC | 216 ms
71,552 KB |
ソースコード
#include <stdio.h> int q[6000000][3]; int main() { int i, H, W, s[2], g[2]; char A[1002][1002] = {}; scanf("%d %d", &H, &W); scanf("%d %d", &(s[0]), &(s[1])); scanf("%d %d", &(g[0]), &(g[1])); for (i = 1; i <= H; i++) scanf("%s", &(A[i][1])); const int sup = 1 << 30; int j, k, l, dist[6][1001][1001], head, tail; for (k = 0; k < 6; k++) for (i = 1; i <= H; i++) for (j = 1; j <= W; j++) dist[k][i][j] = sup; dist[0][s[0]][s[1]] = 0; q[0][0] = 0; q[0][1] = s[0]; q[0][2] = s[1]; for (head = 0, tail = 1; head < tail; head++) { k = q[head][0]; i = q[head][1]; j = q[head][2]; if (A[i-1][j] == '.') { switch (k) { case 0: l = 1; break; case 1: l = 5; break; case 2: l = 2; break; case 3: l = 0; break; case 4: l = 4; break; case 5: l = 3; break; } if (dist[l][i-1][j] == sup) { dist[l][i-1][j] = dist[k][i][j] + 1; q[tail][0] = l; q[tail][1] = i - 1; q[tail++][2] = j; } } if (A[i+1][j] == '.') { switch (k) { case 0: l = 3; break; case 1: l = 0; break; case 2: l = 2; break; case 3: l = 5; break; case 4: l = 4; break; case 5: l = 1; break; } if (dist[l][i+1][j] == sup) { dist[l][i+1][j] = dist[k][i][j] + 1; q[tail][0] = l; q[tail][1] = i + 1; q[tail++][2] = j; } } if (A[i][j-1] == '.') { switch (k) { case 0: l = 4; break; case 1: l = 1; break; case 2: l = 0; break; case 3: l = 3; break; case 4: l = 5; break; case 5: l = 2; break; } if (dist[l][i][j-1] == sup) { dist[l][i][j-1] = dist[k][i][j] + 1; q[tail][0] = l; q[tail][1] = i; q[tail++][2] = j - 1; } } if (A[i][j+1] == '.') { switch (k) { case 0: l = 2; break; case 1: l = 1; break; case 2: l = 5; break; case 3: l = 3; break; case 4: l = 0; break; case 5: l = 4; break; } if (dist[l][i][j+1] == sup) { dist[l][i][j+1] = dist[k][i][j] + 1; q[tail][0] = l; q[tail][1] = i; q[tail++][2] = j + 1; } } } if (dist[0][g[0]][g[1]] == sup) printf("-1\n"); else printf("%d\n", dist[0][g[0]][g[1]]); fflush(stdout); return 0; }