結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー chineristACchineristAC
提出日時 2022-05-20 22:02:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 102,024 KB
最終ジャッジ日時 2023-10-20 12:42:06
合計ジャッジ時間 9,973 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
56,232 KB
testcase_01 AC 45 ms
56,232 KB
testcase_02 AC 48 ms
56,232 KB
testcase_03 AC 46 ms
56,232 KB
testcase_04 AC 45 ms
56,232 KB
testcase_05 AC 45 ms
56,232 KB
testcase_06 AC 47 ms
56,232 KB
testcase_07 AC 431 ms
81,728 KB
testcase_08 AC 87 ms
78,844 KB
testcase_09 AC 462 ms
81,724 KB
testcase_10 AC 488 ms
81,976 KB
testcase_11 AC 536 ms
82,212 KB
testcase_12 AC 523 ms
82,696 KB
testcase_13 AC 527 ms
82,460 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 75 ms
77,744 KB
testcase_17 AC 1,076 ms
97,016 KB
testcase_18 AC 74 ms
77,748 KB
testcase_19 WA -
testcase_20 AC 46 ms
56,236 KB
testcase_21 AC 49 ms
56,236 KB
testcase_22 AC 736 ms
91,116 KB
testcase_23 AC 45 ms
56,236 KB
testcase_24 AC 328 ms
81,660 KB
testcase_25 AC 464 ms
82,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")

    
0