結果
| 問題 | No.2928 Gridpath |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-11 19:18:09 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 134 ms / 2,000 ms |
| + 484µs | |
| コード長 | 1,028 bytes |
| 記録 | |
| コンパイル時間 | 376 ms |
| コンパイル使用メモリ | 64,688 KB |
| 実行使用メモリ | 59,944 KB |
| 最終ジャッジ日時 | 2026-11-11 19:18:14 |
| 合計ジャッジ時間 | 4,383 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import sys
sys.setrecursionlimit(10**8)
H, W = (int(x) for x in input().split())
Si, Sj = (int(x) for x in input().split())
Gi, Gj = (int(x) for x in input().split())
visited = [[False]*W for i in range(H)]
bar = [[0]*W for i in range(H)]
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
visited[Si-1][Sj-1] = True
ans = 0
def dfs(i, j):
global ans
if i == Gi-1 and j == Gj-1:
ans += 1
return
for k, l in move:
if 0 <= i+k < H and 0 <= j+l < W and not visited[i+k][j+l] and bar[i+k][j+l] == 0:
visited[i+k][j+l] = True
for kk, ll in move:
if 0 <= i+kk < H and 0 <= j+ll < W and (not visited[i+kk][j+ll]) and (not (k == kk and l == ll)):
bar[i+kk][j+ll] += 1
dfs(i+k, j+l)
for kk, ll in move:
if 0 <= i+kk < H and 0 <= j+ll < W and (not visited[i+kk][j+ll]) and (not (k == kk and l == ll)):
bar[i+kk][j+ll] -= 1
visited[i+k][j+l] = False
dfs(Si-1, Sj-1)
print(ans)