結果
問題 | No.1572 XI |
ユーザー | mkawa2 |
提出日時 | 2021-06-27 14:08:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,828 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 237,656 KB |
最終ジャッジ日時 | 2024-06-25 11:33:53 |
合計ジャッジ時間 | 26,163 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
53,760 KB |
testcase_01 | AC | 43 ms
54,272 KB |
testcase_02 | AC | 43 ms
53,888 KB |
testcase_03 | AC | 44 ms
54,400 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 251 ms
82,180 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | AC | 39 ms
54,528 KB |
testcase_27 | AC | 43 ms
53,760 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 45 ms
54,272 KB |
testcase_32 | AC | 40 ms
54,400 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 285 ms
189,352 KB |
testcase_48 | WA | - |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from collections import deque move = [[1, 5, 3, 4], [2, 1, 0, 1], [3, 4, 1, 5], [0, 3, 2, 3], [4, 0, 4, 2], [5, 2, 5, 0]] h, w = LI() si, sj = LI1() gi, gj = LI1() aa = [a == "." for _ in range(h) for a in SI()] dp = [[-1]*6 for _ in range(h*w)] q = deque() q.append((si*w+sj, 0)) dp[si*w+si][0] = 0 while q and dp[gi*w+gj][0] == -1: ij, s = q.popleft() i, j = divmod(ij, w) if i: nij = ij-w ns = move[s][1] if dp[nij][ns] == -1 and aa[nij]: q.append((nij, ns)) dp[nij][ns] = dp[ij][s]+1 if i+1 < h: nij = ij+w ns = move[s][3] if dp[nij][ns] == -1 and aa[nij]: q.append((nij, ns)) dp[nij][ns] = dp[ij][s]+1 if j: nij = ij-1 ns = move[s][2] if dp[nij][ns] == -1 and aa[nij]: q.append((nij, ns)) dp[nij][ns] = dp[ij][s]+1 if j+1 < w: nij = ij+1 ns = move[s][0] if dp[nij][ns] == -1 and aa[nij]: q.append((nij, ns)) dp[nij][ns] = dp[ij][s]+1 print(dp[gi*w+gj][0])