結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-20 22:02:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 932 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 102,376 KB |
| 最終ジャッジ日時 | 2024-09-20 08:10:49 |
| 合計ジャッジ時間 | 9,796 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 WA * 3 |
ソースコード
import sys,random,bisect
from collections import deque,defaultdict
import heapq
from itertools import permutations
from math import gcd
input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
INF = 10**17
H,W,s,t = mi()
A = [li() for i in range(H)]
s,t = s-1,t-1
move = [(-1,0),(1,0),(0,1),(0,-1)]
tmp = A[s][t]
pq = []
insert = [[False]*W for i in range(H)]
for x,y in move:
nx,ny = x+s,y+t
if 0 <= nx < H and 0 <= ny < W:
heapq.heappush(pq,(A[nx][ny],nx,ny))
insert[nx][ny] = True
while pq:
val,x,y = heapq.heappop(pq)
if val < tmp:
tmp += val
for dx,dy in move:
nx,ny = x+dx,y+dy
if 0 <= nx < H and 0 <= ny < W and not insert[nx][ny]:
heapq.heappush(pq,(A[nx][ny],nx,ny))
insert[nx][ny] = True
else:
print("No")
break
else:
print("Yes")