結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 AC 32 ms
10,112 KB
testcase_02 AC 29 ms
10,112 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 374 ms
36,096 KB
testcase_08 AC 556 ms
35,968 KB
testcase_09 AC 312 ms
35,328 KB
testcase_10 AC 644 ms
41,216 KB
testcase_11 AC 424 ms
34,304 KB
testcase_12 AC 665 ms
37,888 KB
testcase_13 AC 273 ms
32,256 KB
testcase_14 AC 119 ms
23,424 KB
testcase_15 AC 725 ms
44,160 KB
testcase_16 AC 486 ms
39,296 KB
testcase_17 AC 525 ms
34,944 KB
testcase_18 AC 178 ms
25,600 KB
testcase_19 AC 321 ms
34,560 KB
testcase_20 AC 292 ms
33,280 KB
testcase_21 AC 533 ms
37,120 KB
testcase_22 AC 746 ms
48,872 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 31 ms
10,112 KB
testcase_28 AC 31 ms
10,112 KB
testcase_29 AC 30 ms
10,112 KB
testcase_30 AC 29 ms
10,112 KB
testcase_31 AC 29 ms
10,112 KB
testcase_32 AC 29 ms
10,112 KB
testcase_33 AC 29 ms
10,112 KB
testcase_34 AC 29 ms
10,112 KB
testcase_35 AC 30 ms
10,112 KB
testcase_36 AC 30 ms
10,112 KB
testcase_37 AC 29 ms
10,112 KB
testcase_38 AC 30 ms
10,112 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 and len(LIST)>1:
    if (DIS[t]-k)%2==0:
        print("Yes")
    else:
        print("No")
    exit()

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

if DIS[t]==0 and len(LIST)==1:
    if N==1:
        if k==0:
            print("Yes")
        else:
            print("No")
    else:
        if k==0:
            print("Yes")
        else:
            print("Unknown")

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)==1 and len(LIST2)==1:
    if k%2==0:
        print("No")
    else:
        print("Unknown")
else:
    print("Unknown")

0