結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー hashi_py
提出日時 2022-05-20 23:26:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 706 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-09-20 09:52:02
合計ジャッジ時間 5,083 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
G = [list(map(int,input().split()))for _ in range(h)]
from sys import setrecursionlimit
setrecursionlimit(300000)
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')

ret = []
def dfs(power,H,W,continued):
    # print(power,H,W,continued)
    if(H==h-1 and W==w-1):
        if(power>G[-1][-1]):
            print("Yes")
            exit()
        else:
            return
    for a,b in ((0,1),(1,0)):
        if(0<=H+a<h and 0<=W+b<w):
            if(G[H+a][W+b]<power):
                dfs(power+G[H+a][W+b],H+a,W+b,continued)
            else:
                if(continued==0):
                    dfs(power,H+a,W+b,continued+1)
dfs(G[0][0],0,0,0)
print("No")
0