結果
| 問題 |
No.3263 違法な散歩道
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-06 13:58:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 727 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 82,004 KB |
| 実行使用メモリ | 696,916 KB |
| 最終ジャッジ日時 | 2025-09-06 13:59:20 |
| 合計ジャッジ時間 | 4,595 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | MLE * 1 -- * 27 |
ソースコード
from collections import deque
N,M=map(int,input().split())
G=[[] for _ in range(N+1)]
for _ in range(M):
U,V=map(int,input().split())
G[U].append(V)
G[V].append(U)
K=int(input())
A=set()
if K:A=set(map(int,input().split()))
vis=[0 for _ in range(N+1)]
Q=deque()
Q.append((1,0,0,tuple(vis)))
while Q:
now,step,cnt,vis=Q.popleft()
vis=list(vis)
if now not in A:
cnt=0
vis=[0 for _ in range(N+1)]
vis[now]=1
if now==N:
exit(print(step))
for nxt in G[now]:
if vis[nxt]:continue
if cnt==4:
if nxt in A:continue
else:Q.append((nxt,step+1,cnt+1,tuple(vis)))
else:
Q.append((nxt,step+1,cnt+1,tuple(vis)))
print(-1)