結果

問題 No.2674 k-Walk on Bipartite
ユーザー hiro1729hiro1729
提出日時 2024-03-15 22:37:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 97,868 KB
最終ジャッジ日時 2024-03-15 22:37:47
合計ジャッジ時間 7,351 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,600 KB
testcase_01 AC 48 ms
55,600 KB
testcase_02 AC 41 ms
55,600 KB
testcase_03 AC 42 ms
55,600 KB
testcase_04 AC 42 ms
55,600 KB
testcase_05 AC 41 ms
55,600 KB
testcase_06 AC 41 ms
55,600 KB
testcase_07 AC 294 ms
92,940 KB
testcase_08 AC 330 ms
89,940 KB
testcase_09 AC 210 ms
93,244 KB
testcase_10 AC 388 ms
92,920 KB
testcase_11 AC 302 ms
89,760 KB
testcase_12 AC 369 ms
90,240 KB
testcase_13 AC 193 ms
89,588 KB
testcase_14 AC 103 ms
83,340 KB
testcase_15 AC 443 ms
95,468 KB
testcase_16 AC 296 ms
94,768 KB
testcase_17 AC 316 ms
89,648 KB
testcase_18 AC 144 ms
85,208 KB
testcase_19 AC 229 ms
91,524 KB
testcase_20 AC 221 ms
92,532 KB
testcase_21 AC 320 ms
90,908 KB
testcase_22 AC 439 ms
97,868 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 40 ms
55,600 KB
testcase_28 AC 42 ms
55,600 KB
testcase_29 AC 41 ms
55,600 KB
testcase_30 AC 41 ms
55,600 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 41 ms
55,600 KB
testcase_36 AC 40 ms
55,600 KB
testcase_37 AC 41 ms
55,600 KB
testcase_38 AC 43 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

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:
	if N == 1:
		print("No")
	elif N == 2:
		if d[t] == 0:
			# s == t
			if d[1 - t] == 1:
				if k % 2 == 1:
					print("Yes")
				else:
					print("No")
			else:
				if k % 2 == 1:
					print("Unknown")
				else:
					print("No")
		else:
			# s != t
			print("Yes" if k % 2 == 1 else "No")
	elif d[t] % 2 == k % 2:
		print("Yes" if d[t] <= k else "Unknown")
	else:
		print("No")
else:
	if N == 2 and g[s] == [] and g[t] == [] and k % 2 == 0:
		print("No")
	else:
		print("Unknown")
0