結果
問題 | No.1638 Robot Maze |
ユーザー | U S |
提出日時 | 2021-08-06 22:10:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 1,559 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 80,512 KB |
最終ジャッジ日時 | 2024-09-17 02:12:12 |
合計ジャッジ時間 | 5,734 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
61,184 KB |
testcase_01 | AC | 45 ms
60,928 KB |
testcase_02 | AC | 45 ms
60,928 KB |
testcase_03 | AC | 99 ms
79,408 KB |
testcase_04 | AC | 48 ms
61,568 KB |
testcase_05 | AC | 45 ms
61,440 KB |
testcase_06 | AC | 45 ms
61,696 KB |
testcase_07 | AC | 46 ms
61,184 KB |
testcase_08 | AC | 48 ms
61,696 KB |
testcase_09 | AC | 45 ms
61,568 KB |
testcase_10 | AC | 44 ms
61,568 KB |
testcase_11 | AC | 46 ms
61,440 KB |
testcase_12 | AC | 45 ms
61,440 KB |
testcase_13 | AC | 45 ms
61,440 KB |
testcase_14 | AC | 103 ms
78,960 KB |
testcase_15 | AC | 107 ms
78,976 KB |
testcase_16 | AC | 108 ms
79,104 KB |
testcase_17 | AC | 103 ms
79,104 KB |
testcase_18 | AC | 66 ms
73,728 KB |
testcase_19 | AC | 93 ms
78,380 KB |
testcase_20 | AC | 93 ms
78,592 KB |
testcase_21 | AC | 64 ms
73,984 KB |
testcase_22 | AC | 62 ms
73,856 KB |
testcase_23 | AC | 63 ms
73,728 KB |
testcase_24 | AC | 63 ms
73,600 KB |
testcase_25 | AC | 63 ms
73,856 KB |
testcase_26 | AC | 73 ms
78,720 KB |
testcase_27 | AC | 74 ms
78,848 KB |
testcase_28 | AC | 74 ms
78,464 KB |
testcase_29 | AC | 73 ms
78,592 KB |
testcase_30 | AC | 42 ms
61,184 KB |
testcase_31 | AC | 47 ms
61,440 KB |
testcase_32 | AC | 103 ms
79,232 KB |
testcase_33 | AC | 110 ms
79,848 KB |
testcase_34 | AC | 100 ms
79,436 KB |
testcase_35 | AC | 111 ms
79,884 KB |
testcase_36 | AC | 107 ms
80,000 KB |
testcase_37 | AC | 105 ms
79,104 KB |
testcase_38 | AC | 117 ms
80,000 KB |
testcase_39 | AC | 109 ms
80,000 KB |
testcase_40 | AC | 119 ms
80,000 KB |
testcase_41 | AC | 112 ms
79,360 KB |
testcase_42 | AC | 115 ms
80,512 KB |
testcase_43 | AC | 134 ms
80,000 KB |
testcase_44 | AC | 127 ms
79,972 KB |
testcase_45 | AC | 138 ms
79,872 KB |
testcase_46 | AC | 119 ms
79,988 KB |
testcase_47 | AC | 111 ms
79,232 KB |
testcase_48 | AC | 105 ms
79,724 KB |
testcase_49 | AC | 114 ms
79,872 KB |
testcase_50 | AC | 106 ms
79,360 KB |
testcase_51 | AC | 128 ms
79,872 KB |
ソースコード
# import sys # #sys.setrecursionlimit(1000000) # input = sys.stdin.readline def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) import math import bisect from copy import deepcopy as dc from itertools import accumulate from collections import Counter, defaultdict, deque import itertools def ceil(U,V):return (U+V-1)//V def modf1(N,MOD):return (N-1)%MOD+1 inf = int(1e30) mod = int(1e9+7) import heapq def dijkstra(start,edge): # edge[i] = [(distance, j), ...] dist = [inf]*len(edge) dist[start] = 0 q = [(0, start)] while q: # u から v に辺を張る cost, u = heapq.heappop(q) if dist[u] < cost:continue for ncost, v in edge[u]: if (dist[u]+ncost) < dist[v]: dist[v] = dist[u]+ncost heapq.heappush(q, (dist[v], v)) return dist h,w = mp() u,d,r,l,K,p = mp() sx,sy,gx,gy = mp() sx -= 1 sy -= 1 gx -= 1 gy -= 1 start = sx*h+sy goal = gx*h+gy grid = [input() for i in range(h)] edge = [[] for i in range(h*w)] mx = [1,0,-1,0] my = [0,1,0,-1] c = [d, r, u, l] for i in range(h): for j in range(w): for k in range(4): nx,ny = i+mx[k], j+my[k] if 0 <= nx < h and 0 <= ny < w: if grid[nx][ny] == "#":continue if grid[nx][ny] == "@": cost = c[k] + p else: cost = c[k] edge[i*h+j].append((cost,nx*h+ny)) ans = dijkstra(start,edge)[goal] if ans <= K:print("Yes") else:print("No")