結果
問題 | No.2928 Gridpath |
ユーザー |
|
提出日時 | 2025-02-07 16:37:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 83,032 KB |
実行使用メモリ | 76,564 KB |
最終ジャッジ日時 | 2025-02-07 16:37:19 |
合計ジャッジ時間 | 3,007 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
h,w=map(int,input().split())int1=lambda x:int(x)-1si,sj=map(int1,input().split())gi,gj=map(int1,input().split())F=[[0]*w for _ in range(h)]ans=0def dfs(x,y):global ansif (x,y)==(gi,gj):ans+=1else:F[x][y]=1for i,j in [(0,1),(0,-1),(1,0),(-1,0)]:nx,ny=x+i,y+jif 0<=nx<h and 0<=ny<w and F[nx][ny]==0:stc=0for ii, jj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:nnx, nny = nx + ii, ny + jjif 0<=nnx<h and 0<=nny<w and F[nnx][nny]==1:stc+=1if stc==1:dfs(nx,ny)F[x][y]=0dfs(si,sj)print(ans)