結果

問題 No.2674 k-Walk on Bipartite
ユーザー nikoro256nikoro256
提出日時 2024-03-19 15:46:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 99,280 KB
最終ジャッジ日時 2024-03-19 15:46:14
合計ジャッジ時間 7,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,608 KB
testcase_01 AC 40 ms
55,608 KB
testcase_02 AC 40 ms
55,608 KB
testcase_03 AC 40 ms
55,608 KB
testcase_04 AC 42 ms
55,608 KB
testcase_05 AC 43 ms
55,608 KB
testcase_06 AC 42 ms
55,608 KB
testcase_07 AC 246 ms
92,948 KB
testcase_08 AC 285 ms
92,508 KB
testcase_09 AC 202 ms
93,120 KB
testcase_10 AC 378 ms
95,996 KB
testcase_11 AC 255 ms
90,660 KB
testcase_12 AC 333 ms
93,316 KB
testcase_13 AC 180 ms
89,464 KB
testcase_14 AC 102 ms
83,216 KB
testcase_15 AC 446 ms
97,264 KB
testcase_16 AC 274 ms
94,644 KB
testcase_17 AC 291 ms
90,420 KB
testcase_18 AC 146 ms
85,088 KB
testcase_19 AC 214 ms
91,528 KB
testcase_20 AC 213 ms
92,408 KB
testcase_21 AC 308 ms
93,348 KB
testcase_22 AC 404 ms
99,280 KB
testcase_23 AC 40 ms
55,608 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 40 ms
55,608 KB
testcase_27 AC 42 ms
55,608 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 41 ms
55,608 KB
testcase_31 AC 41 ms
55,608 KB
testcase_32 AC 41 ms
55,608 KB
testcase_33 AC 40 ms
55,608 KB
testcase_34 AC 40 ms
55,608 KB
testcase_35 AC 43 ms
55,608 KB
testcase_36 AC 42 ms
55,608 KB
testcase_37 AC 44 ms
55,608 KB
testcase_38 AC 41 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def bfs(s):
    dq=deque()
    dq.append([s,0])
    high=[10**9 for _ in range(N)]
    high[s]=0
    while len(dq)!=0:
        p,h=dq.popleft()
        for e in edge[p]:
            if  high[e]==10**9:
                dq.append([e,h+1])
                high[e]=h+1
    return high

N,M=map(int,input().split())
s,t,k=map(int,input().split())
if N==1:
    print('No')
    exit(0)
s-=1
t-=1
edge=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
dist=bfs(s)
if dist[t]==10**9:
    print('Unknown')
elif dist[t]%2!=k%2:
    print('No')
elif dist[t]<=k:
    print('Yes')
else:
    print('Unknown')
0