結果
問題 | No.2928 Gridpath |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:39:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 434 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 76,828 KB |
最終ジャッジ日時 | 2024-10-12 15:39:26 |
合計ジャッジ時間 | 2,967 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
H,W=map(int,input().split()) s0,s1=map(int,input().split()) g0,g1=map(int,input().split()) s0-=1;s1-=1 g0-=1;g1-=1 queue=[[(s0,s1)]] ans=0 while queue: route=queue.pop() x,y=route[-1] if (x,y)==(g0,g1): ans+=1 for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)): if 0<=x+dx<H and 0<=y+dy<W and all(abs(xx-(x+dx))+abs(yy-(y+dy))>=2 for xx,yy in route[:-1]): queue.append(route+[(x+dx,y+dy)]) print(ans)