結果
問題 |
No.2674 k-Walk on Bipartite
|
ユーザー |
|
提出日時 | 2024-03-15 22:22:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 769 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 112,316 KB |
最終ジャッジ日時 | 2024-09-30 01:45:34 |
合計ジャッジ時間 | 6,359 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 4 |
ソースコード
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 s==t and k%2==1:exit(print("No")) 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")