結果
| 問題 | No.2928 Gridpath |
| コンテスト | |
| ユーザー |
Cecil
|
| 提出日時 | 2024-10-18 12:07:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 156 ms / 2,000 ms |
| コード長 | 962 bytes |
| 記録 | |
| コンパイル時間 | 539 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 78,020 KB |
| 最終ジャッジ日時 | 2024-10-18 12:07:56 |
| 合計ジャッジ時間 | 3,279 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
from collections import deque
import sys
sys.setrecursionlimit(1 << 20)
H,W=map(int,input().split())
Si,Sj=map(int,input().split())
Gi,Gj=map(int,input().split())
d=[[1,0],[0,1],[-1,0],[0,-1]]
global ans
ans=0
seen=[[False for j in range(W)] for i in range(H)]
def dfs(x1,y1):
global ans
seen[x1][y1]=True
#print(seen[0])
#print(seen[1])
#print("###")
if x1==Gi-1 and y1==Gj-1:
ans += 1
seen[x1][y1] = False
#print("#")
return
for x,y in d:
x2=x1+x
y2=y1+y
if not (0<=y2<W):continue
if not (0<=x2<H):continue
if seen[x2][y2]:continue
cnt=0
for xx,yy in d:
xt=x2+xx
yt=y2+yy
if not (0<=yt<W):continue
if not (0<=xt<H):continue
if seen[xt][yt]:cnt +=1
if cnt>1:
continue
else:
dfs(x2,y2)
seen[x1][y1] = False
dfs(Si-1,Sj-1)
print(ans)
Cecil