結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
9,984 KB
testcase_01 AC 33 ms
9,984 KB
testcase_02 AC 32 ms
9,984 KB
testcase_03 AC 32 ms
9,984 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 31 ms
9,984 KB
testcase_07 AC 428 ms
36,096 KB
testcase_08 AC 593 ms
35,968 KB
testcase_09 WA -
testcase_10 AC 685 ms
41,312 KB
testcase_11 WA -
testcase_12 AC 728 ms
37,976 KB
testcase_13 WA -
testcase_14 AC 128 ms
23,424 KB
testcase_15 AC 735 ms
44,244 KB
testcase_16 AC 504 ms
39,424 KB
testcase_17 AC 539 ms
34,816 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 310 ms
33,280 KB
testcase_21 AC 608 ms
37,248 KB
testcase_22 WA -
testcase_23 AC 31 ms
9,984 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 31 ms
9,984 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 31 ms
9,984 KB
testcase_32 AC 32 ms
9,984 KB
testcase_33 AC 31 ms
9,984 KB
testcase_34 AC 31 ms
9,984 KB
testcase_35 AC 31 ms
9,984 KB
testcase_36 AC 32 ms
9,984 KB
testcase_37 AC 32 ms
9,984 KB
testcase_38 AC 32 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
s,t,k=map(int,input().split())
s-=1
t-=1

E=[[] for i in range(N)]

for i in range(M):
    u,v=map(int,input().split())
    u-=1
    v-=1
    E[u].append(v)
    E[v].append(u)

DIS=[-1]*N
Q=[s]
DIS[s]=0
LIST=[]

while Q:
    x=Q.pop()
    LIST.append(x)
    for to in E[x]:
        if DIS[to]==-1:
            DIS[to]=DIS[x]+1
            Q.append(to)

if 0<=DIS[t]<=k:
    if (DIS[t]-k)%2==0:
        print("Yes")
    else:
        print("No")
    exit()

if DIS[t]>k:
    if (DIS[t]-k)%2==0:
        print("Unknown")
    else:
        print("No")
    exit()

DIS2=[-1]*N
Q=[t]
DIS2[t]=0
LIST2=[]

while Q:
    x=Q.pop()
    LIST2.append(x)
    for to in E[x]:
        if DIS2[to]==-1:
            DIS2[to]=DIS2[x]+1
            Q.append(to)


if max(DIS)+max(DIS2)+1<=k:
    print("Yes")
else:
    print("Unknown")

0