結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,604 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 41 ms
55,604 KB
testcase_03 AC 41 ms
55,604 KB
testcase_04 AC 41 ms
55,604 KB
testcase_05 AC 41 ms
55,604 KB
testcase_06 AC 40 ms
55,604 KB
testcase_07 AC 300 ms
92,940 KB
testcase_08 AC 337 ms
89,940 KB
testcase_09 AC 222 ms
93,240 KB
testcase_10 AC 414 ms
92,916 KB
testcase_11 AC 297 ms
89,768 KB
testcase_12 AC 370 ms
90,236 KB
testcase_13 AC 188 ms
89,584 KB
testcase_14 AC 103 ms
83,336 KB
testcase_15 AC 473 ms
95,592 KB
testcase_16 AC 302 ms
94,636 KB
testcase_17 AC 340 ms
89,644 KB
testcase_18 AC 140 ms
85,208 KB
testcase_19 AC 224 ms
91,520 KB
testcase_20 AC 205 ms
92,528 KB
testcase_21 AC 332 ms
90,908 KB
testcase_22 AC 444 ms
97,864 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 42 ms
55,604 KB
testcase_29 AC 44 ms
55,604 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 40 ms
55,604 KB
testcase_36 AC 41 ms
55,604 KB
testcase_37 AC 41 ms
55,604 KB
testcase_38 AC 41 ms
55,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n, m = map(int, input().split())
s, t, k = map(int, input().split())
if n == 1:
    print("No")
    exit()
elif n == 2:
    if k % 2 == 1:
        print("Yes")
    else:
        print("No")
    exit()

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

queue = deque()
dist = [-1] * n
dist[s] = 0
queue.append(s)
while queue:
    pos = queue.popleft()
    for npos in edges[pos]:
        if dist[npos] != -1:
            continue
        dist[npos] = dist[pos] + 1
        queue.append(npos)

if dist[t] == -1:
    print("Unknown")
elif dist[t] % 2 != k % 2:
    print("No")
elif dist[t] <= k:
    print("Yes")
else:
    print("Unknown")
0