結果

問題 No.2674 k-Walk on Bipartite
ユーザー moon17
提出日時 2025-03-23 21:01:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 82,948 KB
実行使用メモリ 118,912 KB
最終ジャッジ日時 2025-03-23 21:01:22
合計ジャッジ時間 8,322 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

(n,m),(S,T,k),*e=[[*map(int,s.split())]for s in open(0)]
S-=1;T-=1
g=[[]for _ in range(n)]
for a,b in e:
  a-=1;b-=1
  g[a]+=b,
  g[b]+=a,
s=[-1]*n
s[S]=0
t=[-1]*n
t[S]=0
q=[S]
while q:
  p=q.pop()
  for v in g[p]:
    if s[v]<0:
      s[v]=s[p]^1
      t[v]=t[p]+1
      q+=v,
if s[T]==-1:
  exit(print('Unknown'))
if s[S]==s[T]:
  if k%2==0:
    if t[T]<=k:
      print('Yes')
    else:
      print('Unknown')
  else:
    print('No')
else:
  if k%2:
    if t[T]<=k:
      print('Yes')
    else:
      print('Unknown')
  else:
    print('No')
0