結果

問題 No.2674 k-Walk on Bipartite
ユーザー hiro1729
提出日時 2024-03-15 22:32:43
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 517 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 98,132 KB
最終ジャッジ日時 2024-09-30 01:58:13
合計ジャッジ時間 7,758 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other AC * 10 RE * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N, M = map(int, input().split())
s, t, k = map(int, input().split())
s -= 1
t -= 1
g = [[] for _ in range(N)]
for _ in range(M):
	u, v = map(int, input().split())
	u -= 1
	v -= 1
	g[u].append(v)
	g[v].append(u)
d = [10 ** 9] * N
d[s] = 0
q = deque([s])
while q:
	u = q.popleft()
	for v in g[u]:
		if d[u] + 1 < d[v]:
			d[v] = d[u] + 1
			q.append(v)
if d[t] < 10 ** 9:
	assert(False)
else:
	if N == 2 and g[s] == [] and g[t] == [] and k % 2 == 0:
		print("No")
	else:
		print("Unknown")
0