結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,460 KB
testcase_01 AC 44 ms
53,460 KB
testcase_02 AC 46 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 40 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 373 ms
93,880 KB
testcase_08 AC 453 ms
93,180 KB
testcase_09 AC 195 ms
92,012 KB
testcase_10 AC 583 ms
96,904 KB
testcase_11 AC 378 ms
91,176 KB
testcase_12 AC 558 ms
94,128 KB
testcase_13 AC 186 ms
90,384 KB
testcase_14 AC 91 ms
83,228 KB
testcase_15 AC 601 ms
99,272 KB
testcase_16 AC 422 ms
95,200 KB
testcase_17 AC 437 ms
92,588 KB
testcase_18 AC 136 ms
85,592 KB
testcase_19 AC 215 ms
91,424 KB
testcase_20 AC 213 ms
91,420 KB
testcase_21 AC 467 ms
94,300 KB
testcase_22 AC 620 ms
101,296 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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()


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 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