結果

問題 No.2928 Gridpath
ユーザー prd_xxx
提出日時 2024-10-12 16:56:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 673 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 782,848 KB
最終ジャッジ日時 2024-10-12 16:56:27
合計ジャッジ時間 3,934 ms
ジャッジサーバーID
(参考情報)
judge5 / judge
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 1
other -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**8)
H,W = map(int,input().split())
si,sj = map(lambda x:int(x)-1,input().split())
gi,gj = map(lambda x:int(x)-1,input().split())

D = {'R':(0,1), 'D':(1,0), 'L':(0,-1), 'U':(-1,0)}
R = {'R':'L', 'D':'U', 'L':'R', 'U':'D', '_':'*'}
S = {'R':'UD', 'D':'LR', 'L':'UD', 'U':'LR', '_':''}

ans = 0
def rec(i,j,p,pp):
    global ans
    if (i,j)==(gi,gj):
        ans += 1
        return
    for d,(di,dj) in D.items():
        if d==R[p]: continue
        ni,nj = i+di,j+dj
        if not (0<=ni<H and 0<=nj<W): continue
        np,npp = d,p
        if R[d]==pp and p in S[d]: continue
        rec(ni,nj,np,npp)
rec(si,sj,'_','_')

print(ans)
0