結果
問題 | No.1638 Robot Maze |
ユーザー | yudai1102jp |
提出日時 | 2021-08-06 23:33:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,811 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 82,556 KB |
実行使用メモリ | 77,948 KB |
最終ジャッジ日時 | 2024-09-17 04:08:51 |
合計ジャッジ時間 | 4,918 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
53,852 KB |
testcase_01 | AC | 35 ms
53,256 KB |
testcase_02 | AC | 34 ms
53,072 KB |
testcase_03 | AC | 70 ms
77,176 KB |
testcase_04 | AC | 35 ms
53,544 KB |
testcase_05 | AC | 36 ms
53,572 KB |
testcase_06 | AC | 37 ms
53,300 KB |
testcase_07 | AC | 37 ms
55,012 KB |
testcase_08 | AC | 36 ms
53,572 KB |
testcase_09 | AC | 36 ms
53,240 KB |
testcase_10 | AC | 41 ms
54,240 KB |
testcase_11 | AC | 37 ms
54,116 KB |
testcase_12 | AC | 36 ms
53,556 KB |
testcase_13 | AC | 34 ms
53,208 KB |
testcase_14 | WA | - |
testcase_15 | AC | 87 ms
76,740 KB |
testcase_16 | AC | 85 ms
76,824 KB |
testcase_17 | AC | 61 ms
70,128 KB |
testcase_18 | AC | 40 ms
53,860 KB |
testcase_19 | AC | 93 ms
76,868 KB |
testcase_20 | AC | 85 ms
77,104 KB |
testcase_21 | AC | 49 ms
65,880 KB |
testcase_22 | AC | 50 ms
66,104 KB |
testcase_23 | AC | 56 ms
65,236 KB |
testcase_24 | AC | 49 ms
65,620 KB |
testcase_25 | AC | 49 ms
66,060 KB |
testcase_26 | AC | 51 ms
70,212 KB |
testcase_27 | AC | 55 ms
68,748 KB |
testcase_28 | AC | 56 ms
70,284 KB |
testcase_29 | AC | 53 ms
69,072 KB |
testcase_30 | WA | - |
testcase_31 | AC | 34 ms
52,872 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 100 ms
76,900 KB |
testcase_35 | WA | - |
testcase_36 | AC | 111 ms
77,140 KB |
testcase_37 | WA | - |
testcase_38 | AC | 85 ms
76,976 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 38 ms
54,744 KB |
testcase_43 | AC | 85 ms
76,656 KB |
testcase_44 | AC | 83 ms
77,040 KB |
testcase_45 | AC | 100 ms
76,760 KB |
testcase_46 | AC | 78 ms
76,928 KB |
testcase_47 | AC | 94 ms
77,088 KB |
testcase_48 | AC | 110 ms
77,948 KB |
testcase_49 | AC | 90 ms
76,844 KB |
testcase_50 | AC | 93 ms
76,924 KB |
testcase_51 | AC | 95 ms
77,076 KB |
ソースコード
import sys import heapq sys.setrecursionlimit(10**6) # 再帰関数使う時有効 H, W = map(int, input().split()) U, D, R, L, K, P = map(int, input().split()) x, y, xt, yt = map(int, input().split()) start = [x-1, y-1] goal = [xt-1, yt-1] goal_n = goal[0]*W+goal[1] allow = [[1, 0], [0, 1], [-1, 0], [0, -1]] allow_cost = [D, R, U, L] C = [input() for i in range(H)] # def fps(now, cost): # if now == goal: # return cost # ans = 10**13+8 # for i in range(4): # nextx = now[0]+allow[i][0] # nexty = now[1]+allow[i][1] # if not (0 <= nextx < H and 0 <= nexty < W): # continue # if C[nextx][nexty] == '.': # new_cost = cost+allow_cost[i] # elif C[nextx][nexty] == '@': # new_cost = cost+allow_cost[i]+P # else: # continue # ans = min(ans, fps([nextx, nexty], new_cost)) # return ans dp = [[-1]*W for i in range(H)] dp[start[0]][start[1]] = 0 q = [start[0]*W+start[1]] heapq.heapify(q) ok = set() while q: now_n = heapq.heappop(q) now = [now_n//W, now_n % W] if now_n == goal_n: break ok.add(now_n) for i in range(4): nextx = now[0]+allow[i][0] nexty = now[1]+allow[i][1] if not (0 <= nextx < H and 0 <= nexty < W) or C[nextx][nexty] == '#' or nextx*W+nexty in ok: continue if C[nextx][nexty] == '.': new_cost = dp[now[0]][now[1]]+allow_cost[i] elif C[nextx][nexty] == '@': new_cost = dp[now[0]][now[1]]+allow_cost[i]+P if dp[nextx][nexty] == -1 or dp[nextx][nexty] > new_cost: dp[nextx][nexty] = new_cost heapq.heappush(q, nextx*W+nexty) if dp[goal[0]][goal[1]] <= K and dp[goal[0]][goal[1]] != -1: print('Yes') else: print('No')