結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2022-05-20 21:50:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 885 ms / 3,000 ms |
| コード長 | 834 bytes |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 82,916 KB |
| 実行使用メモリ | 100,960 KB |
| 最終ジャッジ日時 | 2024-09-20 07:52:52 |
| 合計ジャッジ時間 | 8,158 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
"""
"""
import sys
from sys import stdin
from collections import deque
import heapq
H,W,X,Y = map(int,stdin.readline().split())
X -= 1
Y -= 1
A = [ 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] = False
q = []
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] = False
heapq.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 += cost
for 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] = False
heapq.heappush( q,(A[i][j] , i,j) )
#print (now,q)
print ("Yes")
SPD_9X2