結果

問題 No.3291 K-step Navigation
コンテスト
ユーザー RyosukeFukatani
提出日時 2025-09-12 20:42:39
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 664 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 539 ms
コンパイル使用メモリ 21,408 KB
実行使用メモリ 15,996 KB
最終ジャッジ日時 2026-07-15 00:28:14
合計ジャッジ時間 8,638 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 42 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    n, m, k, s, t = list(map(int, input().split()))
    s -= 1
    t -= 1
    s, t = min(s, t), max(s, t)

    count = [0] * n
    st_connected = False

    for _ in range(m):
        u, v = list(map(int, input().split()))
        u -= 1
        v -= 1
        u, v = min(u, v), max(u, v)
        count[u] += 1
        count[v] += 1
        if s == u and t == v:
            st_connected = True

    if (count[s] == 0 and count[t] == 0) or (count[s] == 1 and count[t] == 1 and st_connected):
        if k % 2 == 1:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    solve()

0