結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 AC 34 ms
9,984 KB
testcase_02 AC 32 ms
9,984 KB
testcase_03 AC 30 ms
9,984 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 29 ms
9,984 KB
testcase_07 AC 379 ms
35,968 KB
testcase_08 AC 543 ms
35,840 KB
testcase_09 AC 294 ms
35,328 KB
testcase_10 AC 652 ms
41,192 KB
testcase_11 AC 434 ms
34,304 KB
testcase_12 AC 650 ms
37,856 KB
testcase_13 AC 268 ms
32,256 KB
testcase_14 AC 119 ms
23,296 KB
testcase_15 AC 698 ms
44,124 KB
testcase_16 AC 492 ms
39,296 KB
testcase_17 AC 514 ms
34,816 KB
testcase_18 AC 179 ms
25,472 KB
testcase_19 AC 327 ms
34,560 KB
testcase_20 AC 292 ms
33,152 KB
testcase_21 AC 538 ms
37,376 KB
testcase_22 AC 713 ms
48,896 KB
testcase_23 AC 29 ms
9,984 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 29 ms
9,984 KB
testcase_27 AC 29 ms
9,984 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 29 ms
9,984 KB
testcase_31 AC 29 ms
9,984 KB
testcase_32 AC 29 ms
9,984 KB
testcase_33 AC 29 ms
9,984 KB
testcase_34 AC 30 ms
9,984 KB
testcase_35 AC 29 ms
9,984 KB
testcase_36 AC 30 ms
9,984 KB
testcase_37 AC 29 ms
9,984 KB
testcase_38 AC 29 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 len(LIST)==0 and len(LIST2)==0:
    if k%2==0:
        print("No")
    else:
        print("Unknown")
else:
    print("Unknown")

0