結果

問題 No.2674 k-Walk on Bipartite
ユーザー miho-4
提出日時 2024-03-15 22:18:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 112,248 KB
最終ジャッジ日時 2024-09-30 01:39:38
合計ジャッジ時間 6,051 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,m=map(int,input().split())
s,t,k=map(int,input().split())
edge=[list(map(int,input().split())) for _ in range(m)]

E=[[] for _ in range(n+1)]
for u,v in edge:
  E[v].append(u)
  E[u].append(v)
  
D=[10**9]*(n+1)
P=[-1]*(n+1)
D[s],P[s]=0,0
q=deque([(s)])
while q:
  x=q.popleft()
  for e in E[x]:
    if D[x]+1<D[e]:
      P[e]=P[x]^1
      D[e]=D[x]+1
      q.append(e)

if P[t]==0:
  if k%2==1:
    print("No")
  else:
    if D[t]<=k:
      print("Yes")
    else:
      print("Unknown")
elif P[t]==1:
  if k%2==0:
    print("No")
  else:
    if D[t]<=k:
      print("Yes")
    else:
      print("Unknown")
else:
  if n==1:print("No")
  elif n==2 and k%2==0:print("No")
  else:
    print("Unknown")
0