結果

問題 No.2674 k-Walk on Bipartite
ユーザー Today03Today03
提出日時 2024-03-16 06:56:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,067 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-03-16 06:56:33
合計ジャッジ時間 12,577 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 AC 29 ms
9,984 KB
testcase_02 AC 31 ms
9,984 KB
testcase_03 AC 33 ms
9,984 KB
testcase_04 AC 30 ms
9,984 KB
testcase_05 AC 34 ms
9,984 KB
testcase_06 AC 29 ms
9,984 KB
testcase_07 AC 552 ms
34,304 KB
testcase_08 AC 760 ms
31,744 KB
testcase_09 AC 464 ms
33,920 KB
testcase_10 AC 900 ms
36,352 KB
testcase_11 AC 615 ms
29,952 KB
testcase_12 AC 938 ms
34,048 KB
testcase_13 AC 412 ms
31,104 KB
testcase_14 AC 138 ms
23,424 KB
testcase_15 AC 972 ms
38,656 KB
testcase_16 AC 668 ms
36,224 KB
testcase_17 AC 717 ms
30,848 KB
testcase_18 AC 270 ms
24,704 KB
testcase_19 AC 519 ms
33,408 KB
testcase_20 AC 450 ms
33,280 KB
testcase_21 AC 746 ms
32,768 KB
testcase_22 AC 1,067 ms
41,472 KB
testcase_23 AC 28 ms
9,984 KB
testcase_24 AC 29 ms
9,984 KB
testcase_25 AC 30 ms
9,984 KB
testcase_26 AC 29 ms
9,984 KB
testcase_27 AC 29 ms
9,984 KB
testcase_28 AC 29 ms
9,984 KB
testcase_29 AC 28 ms
9,984 KB
testcase_30 AC 29 ms
9,984 KB
testcase_31 AC 28 ms
9,984 KB
testcase_32 AC 28 ms
9,984 KB
testcase_33 AC 30 ms
9,984 KB
testcase_34 AC 28 ms
9,984 KB
testcase_35 AC 28 ms
9,984 KB
testcase_36 AC 28 ms
9,984 KB
testcase_37 AC 29 ms
9,984 KB
testcase_38 AC 31 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())
S, T, K = map(int, input().split())
S, T = S - 1, T - 1
G = [[] for _ in range(N)]
INF = 10**9
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A - 1, B - 1
    G[A].append(B)
    G[B].append(A)

if N == 1:
    print("No")
    exit()

D = [INF] * N
D[S] = 0
Q = deque()
Q.append(S)

while Q:
    now = Q.popleft()
    for nxt in G[now]:
        if D[nxt] > D[now] + 1:
            D[nxt] = D[now] + 1
            Q.append(nxt)

if S == T:
    if K % 2 == 0 and len(G[S]) > 0:
        print("Yes")
    elif K % 2 == 0:
        print("Unknown")
    else:
        print("No")
elif N == 2 and K % 2 == 0:
    print("No")
else:
    if D[T] <= K and D[T] % 2 == K % 2:
        print("Yes")
    elif D[T] == INF or (D[T] != INF and D[T] % 2 == K % 2):
        print("Unknown")
    else:
        print("No")
0