結果

問題 No.2674 k-Walk on Bipartite
ユーザー Today03Today03
提出日時 2024-03-16 06:52:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-03-16 06:52:43
合計ジャッジ時間 12,440 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
9,984 KB
testcase_01 AC 29 ms
9,984 KB
testcase_02 AC 29 ms
9,984 KB
testcase_03 AC 30 ms
9,984 KB
testcase_04 AC 29 ms
9,984 KB
testcase_05 AC 29 ms
9,984 KB
testcase_06 AC 29 ms
9,984 KB
testcase_07 AC 527 ms
34,304 KB
testcase_08 AC 785 ms
31,744 KB
testcase_09 AC 445 ms
33,920 KB
testcase_10 AC 932 ms
36,224 KB
testcase_11 AC 599 ms
29,952 KB
testcase_12 AC 938 ms
34,048 KB
testcase_13 AC 403 ms
31,104 KB
testcase_14 AC 140 ms
23,424 KB
testcase_15 AC 999 ms
38,656 KB
testcase_16 AC 685 ms
36,224 KB
testcase_17 AC 720 ms
30,720 KB
testcase_18 AC 284 ms
24,704 KB
testcase_19 AC 517 ms
33,408 KB
testcase_20 AC 468 ms
33,280 KB
testcase_21 AC 790 ms
32,768 KB
testcase_22 AC 1,061 ms
41,472 KB
testcase_23 AC 29 ms
9,984 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 29 ms
9,984 KB
testcase_27 AC 29 ms
9,984 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 29 ms
9,984 KB
testcase_31 AC 29 ms
9,984 KB
testcase_32 AC 29 ms
9,984 KB
testcase_33 AC 29 ms
9,984 KB
testcase_34 AC 29 ms
9,984 KB
testcase_35 AC 30 ms
9,984 KB
testcase_36 AC 29 ms
9,984 KB
testcase_37 AC 29 ms
9,984 KB
testcase_38 AC 29 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")
    else:
        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