結果
問題 | No.2928 Gridpath |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:33:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 858 bytes |
コンパイル時間 | 331 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 76,880 KB |
最終ジャッジ日時 | 2024-10-12 15:33:31 |
合計ジャッジ時間 | 2,668 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
import sys sys.setrecursionlimit(10**6) import pypyjit pypyjit.set_param('max_unroll_recursion=-1') H,W=map(int,input().split()) Si,Sj=map(int,input().split()) Gi,Gj=map(int,input().split()) Si-=1 Sj-=1 Gi-=1 Gj-=1 ds = [[1,0],[-1,0],[0,1],[0,-1]] ans=0 use = set() def solve(x, y): #print(x, y, use) global ans if x==Gi and y==Gj: ans+=1 return use.add((x,y)) for d in ds: x_ = x+d[0] y_ = y+d[1] if 0<=x_<H and 0<=y_<W: if (x_, y_) in use: continue flag = True for d2 in ds: x2_ = x_+d2[0] y2_ = y_+d2[1] if not (x2_ == x and y2_ == y) and (x2_,y2_) in use: flag = False if flag: solve(x_, y_) use.discard((x,y)) solve(Si,Sj) print(ans)