結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー |
👑 ![]() |
提出日時 | 2022-05-20 21:49:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 833 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 101,996 KB |
最終ジャッジ日時 | 2024-09-20 07:51:29 |
合計ジャッジ時間 | 9,547 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 4 |
ソースコード
""""""import sysfrom sys import stdinfrom collections import dequeimport heapqH,W,X,Y = map(int,stdin.readline().split())X -= 1Y -= 1A = [ list(map(int,stdin.readline().split())) for i in range(H) ]dp = [[True] * W for i in range(H)]q = deque()now = A[X][Y]dp[X][Y] = Falseq = []for i,j in ( (X-1,Y),(X+1,Y),(X,Y-1),(X,Y+1) ):if 0 <= i < H and 0 <= j < W:dp[i][j] = Falseheapq.heappush( q,(A[i][j] , i,j) )while q:cost,x,y = heapq.heappop(q)#print (now,cost,x,y)if cost > now:print ("No")sys.exit()now += costfor i,j in ( (x-1,y),(x+1,y),(x,y-1),(x,y+1) ):if 0 <= i < H and 0 <= j < W and dp[i][j]:dp[i][j] = Falseheapq.heappush( q,(A[i][j] , i,j) )#print (now,q)print ("Yes")