結果

問題 No.2674 k-Walk on Bipartite
ユーザー tassei903tassei903
提出日時 2024-03-15 22:20:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,581 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 101,260 KB
最終ジャッジ日時 2024-03-15 22:20:11
合計ジャッジ時間 9,072 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 43 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 325 ms
93,880 KB
testcase_08 AC 438 ms
93,188 KB
testcase_09 AC 210 ms
92,012 KB
testcase_10 AC 526 ms
96,904 KB
testcase_11 AC 372 ms
91,176 KB
testcase_12 AC 536 ms
94,244 KB
testcase_13 AC 181 ms
90,256 KB
testcase_14 AC 90 ms
83,228 KB
testcase_15 AC 612 ms
99,256 KB
testcase_16 AC 369 ms
95,200 KB
testcase_17 AC 428 ms
92,588 KB
testcase_18 AC 131 ms
85,592 KB
testcase_19 AC 236 ms
91,424 KB
testcase_20 AC 191 ms
91,420 KB
testcase_21 AC 466 ms
94,180 KB
testcase_22 AC 613 ms
101,260 KB
testcase_23 AC 38 ms
53,460 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 39 ms
53,460 KB
testcase_28 AC 38 ms
53,460 KB
testcase_29 AC 39 ms
53,460 KB
testcase_30 AC 39 ms
53,460 KB
testcase_31 AC 38 ms
53,460 KB
testcase_32 AC 37 ms
53,460 KB
testcase_33 AC 38 ms
53,460 KB
testcase_34 AC 37 ms
53,460 KB
testcase_35 AC 37 ms
53,460 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 37 ms
53,460 KB
testcase_38 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n, m = na()
s,t,k = na()
s -= 1
t -= 1

g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

if n == 1:
    No()
    exit()

if n == 2:
    if s == t and m >= 1:
        if k % 2 == 0:
            Yes()
        else:
            No()
    elif s == t and m == 0:
        No()
    elif s != t and m >= 1:
        if k % 2:
            Yes()
        else:
            No()
    else:
        if k % 2:
            print("Unknown")
        else:
            No()
    exit()


from heapq import *
INF = 10**18
def dijkstra(g, s, n):
    dist = [INF]*n
    hq = [(0, s)]
    dist[s] = 0
    while hq:
        d, v = heappop(hq)
        if dist[v]!=d:
            continue
        for to in g[v]:
            c = 1
            if dist[v] + c < dist[to]:
                dist[to] = dist[v] + c
                heappush(hq, (dist[to], to))
    return dist

dist = dijkstra(g, s, n)

if s == t:
    if len(g[s]) == 0:
        No()
    else:
        if k % 2:
            Yes()
        else:
            No()
    exit()


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