結果

問題 No.2674 k-Walk on Bipartite
ユーザー nikoro256
提出日時 2024-03-19 15:44:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 99,584 KB
最終ジャッジ日時 2024-09-30 05:32:25
合計ジャッジ時間 6,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def bfs(s):
    dq=deque()
    dq.append([s,0])
    high=[10**9 for _ in range(N)]
    high[s]=0
    while len(dq)!=0:
        p,h=dq.popleft()
        for e in edge[p]:
            if  high[e]==10**9:
                dq.append([e,h+1])
                high[e]=h+1
    return high

N,M=map(int,input().split())
s,t,k=map(int,input().split())
if N==1:
    print('No')
    exit(0)
s-=1
t-=1
edge=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
dist=bfs(s)
if dist[t]==10**9:
    print('Unknown')
elif dist[t]%2!=k%2:
    print('No')
elif dist[t]<k:
    print('Yes')
else:
    print('Unknown')
0