結果

問題 No.2674 k-Walk on Bipartite
ユーザー i_am_noobi_am_noob
提出日時 2024-03-21 02:35:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 625 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 100,968 KB
最終ジャッジ日時 2024-03-21 02:35:38
合計ジャッジ時間 10,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
68,004 KB
testcase_01 AC 62 ms
68,004 KB
testcase_02 AC 62 ms
68,004 KB
testcase_03 AC 62 ms
68,004 KB
testcase_04 AC 61 ms
68,004 KB
testcase_05 AC 62 ms
68,004 KB
testcase_06 AC 63 ms
68,004 KB
testcase_07 AC 384 ms
96,292 KB
testcase_08 AC 476 ms
93,680 KB
testcase_09 AC 228 ms
93,784 KB
testcase_10 AC 568 ms
96,548 KB
testcase_11 AC 408 ms
93,128 KB
testcase_12 AC 500 ms
93,848 KB
testcase_13 AC 243 ms
92,568 KB
testcase_14 AC 120 ms
83,752 KB
testcase_15 AC 597 ms
99,016 KB
testcase_16 AC 461 ms
97,100 KB
testcase_17 AC 449 ms
93,000 KB
testcase_18 AC 173 ms
88,436 KB
testcase_19 AC 255 ms
91,944 KB
testcase_20 AC 257 ms
92,808 KB
testcase_21 AC 483 ms
94,532 KB
testcase_22 AC 625 ms
100,968 KB
testcase_23 AC 62 ms
68,004 KB
testcase_24 AC 60 ms
68,004 KB
testcase_25 AC 61 ms
68,004 KB
testcase_26 AC 63 ms
68,004 KB
testcase_27 AC 61 ms
68,004 KB
testcase_28 AC 60 ms
68,004 KB
testcase_29 AC 61 ms
68,004 KB
testcase_30 AC 62 ms
68,004 KB
testcase_31 AC 63 ms
68,004 KB
testcase_32 AC 66 ms
68,004 KB
testcase_33 AC 67 ms
68,004 KB
testcase_34 AC 63 ms
68,004 KB
testcase_35 AC 61 ms
68,004 KB
testcase_36 AC 63 ms
68,004 KB
testcase_37 AC 61 ms
68,004 KB
testcase_38 AC 60 ms
68,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
s, t, k = map(int, input().split())
s -= 1
t -= 1
adj = [[] for i in range(n)]
for i in range(m):
	u, v = map(int, input().split())
	u -= 1
	v -= 1
	adj[u].append(v)
	adj[v].append(u)

dis = [1000000000 for i in range(n)]

from queue import *
q = Queue()

q.put(s)
dis[s] = 0

while not q.empty():
	u = q.get()
	q.task_done()
	for v in adj[u]:
		if dis[v] > dis[u] + 1:
			dis[v] = dis[u] + 1
			q.put(v)

if n == 1:
	print("No")
elif s == t:
	if (dis[t] + k) % 2:
		print("No")
	else:
		print("Yes" if adj[s] else "Unknown")
elif dis[t] < 1000000000:
	if (dis[t] + k) % 2:
		print("No")
	elif dis[t] <= k:
		print("Yes")
	else:
		print("Unknown")
elif k % 2:
	print("Unknown")
else:
	print("No" if n == 2 else "Unknown")
0