結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,608 KB
testcase_01 AC 43 ms
55,608 KB
testcase_02 AC 41 ms
55,608 KB
testcase_03 AC 41 ms
55,608 KB
testcase_04 AC 40 ms
55,608 KB
testcase_05 AC 41 ms
55,608 KB
testcase_06 AC 39 ms
55,608 KB
testcase_07 AC 240 ms
92,944 KB
testcase_08 AC 290 ms
92,508 KB
testcase_09 AC 193 ms
93,120 KB
testcase_10 AC 344 ms
95,996 KB
testcase_11 AC 236 ms
90,664 KB
testcase_12 AC 310 ms
93,316 KB
testcase_13 AC 176 ms
89,464 KB
testcase_14 AC 98 ms
83,216 KB
testcase_15 AC 406 ms
97,392 KB
testcase_16 AC 276 ms
94,772 KB
testcase_17 AC 269 ms
90,420 KB
testcase_18 AC 133 ms
85,088 KB
testcase_19 AC 213 ms
91,528 KB
testcase_20 AC 200 ms
92,408 KB
testcase_21 AC 293 ms
93,340 KB
testcase_22 AC 375 ms
99,280 KB
testcase_23 WA -
testcase_24 AC 40 ms
55,608 KB
testcase_25 AC 39 ms
55,608 KB
testcase_26 WA -
testcase_27 AC 39 ms
55,608 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 39 ms
55,608 KB
testcase_31 AC 39 ms
55,608 KB
testcase_32 AC 39 ms
55,608 KB
testcase_33 AC 39 ms
55,608 KB
testcase_34 AC 41 ms
55,608 KB
testcase_35 AC 39 ms
55,608 KB
testcase_36 AC 39 ms
55,608 KB
testcase_37 AC 39 ms
55,608 KB
testcase_38 AC 39 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 s==t:
    if len(edge[s])==0:
        print('Unknown')
        exit(0)
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