結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー pitPpitP
提出日時 2022-05-21 13:19:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 371,696 KB
最終ジャッジ日時 2023-10-20 16:05:13
合計ジャッジ時間 6,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,524 KB
testcase_01 AC 39 ms
53,400 KB
testcase_02 AC 38 ms
53,400 KB
testcase_03 AC 38 ms
53,400 KB
testcase_04 AC 38 ms
53,400 KB
testcase_05 AC 39 ms
53,400 KB
testcase_06 AC 39 ms
53,400 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


h,w,y,x = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
y -= 1
x -= 1

visited = [[False]*w for _ in range(h)]

hq = []
now = a[y][x]
visited[y][x] = True

didj = [(1,0),(0,1),(0,-1),(-1,0)]
for di,dj in didj:
    ni = y + di
    nj = x + dj
    if 0 <= ni < h and 0 <= nj < w:
        heapq.heappush(hq,(a[ni][nj] , (ni,nj)))

while hq:
    a_nxt,(i,j) = heapq.heappop(hq)
    if now <= a_nxt:
        print("No")
        exit()
    now += a_nxt
    visited[i][j] = True
    for di , dj in didj:
        ni = i + di
        nj = j + dj
        if 0 <= ni < h and 0 <= nj < w and not visited[ni][nj]:
            heapq.heappush(hq,(a[ni][nj], (ni,nj)))

print("Yes")
0