結果
問題 |
No.2928 Gridpath
|
ユーザー |
![]() |
提出日時 | 2024-10-12 16:55:25 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 673 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 742,784 KB |
最終ジャッジ日時 | 2024-10-12 16:56:06 |
合計ジャッジ時間 | 3,863 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 1 |
other | -- * 20 |
ソースコード
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)