結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-21 01:02:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 296,624 KB |
| 最終ジャッジ日時 | 2024-09-20 10:54:20 |
| 合計ジャッジ時間 | 5,632 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 TLE * 1 -- * 18 |
ソースコード
from heapq import heappop, heappush
h, w, si, sj = map(int, input().split())
si -= 1
sj -= 1
A = [list(map(int, input().split())) for _ in range(h)]
visited = [[False for _ in range(w)] for _ in range(h)]
visited[si][sj] = True
Heap = []
Directions = [(1, 0), (0, 1), (-1, 0), (0, -1)]
curr = A[si][sj]
for di, dj in Directions:
ni, nj = si + di, sj + dj
if 0 <= ni < h and 0 <= nj < w:
heappush(Heap, (A[ni][nj], ni, nj))
while Heap:
res, ci, cj = heappop(Heap)
if curr <= res:
print("No")
exit()
curr += res
visited[ci][cj] = True
for di, dj in Directions:
ni, nj = ci + di, cj + dj
if 0 <= ni < h and 0 <= nj < w and not visited[ni][nj]:
heappush(Heap, (A[ni][nj], ni, nj))
print("Yes")