結果

問題 No.2674 k-Walk on Bipartite
ユーザー mkawa2mkawa2
提出日時 2024-03-15 23:19:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 97,440 KB
最終ジャッジ日時 2024-03-15 23:19:24
合計ジャッジ時間 7,420 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,736 KB
testcase_01 AC 42 ms
55,736 KB
testcase_02 AC 45 ms
55,736 KB
testcase_03 AC 42 ms
55,736 KB
testcase_04 AC 42 ms
55,736 KB
testcase_05 AC 42 ms
55,736 KB
testcase_06 AC 42 ms
55,736 KB
testcase_07 AC 268 ms
93,404 KB
testcase_08 AC 315 ms
91,000 KB
testcase_09 AC 197 ms
92,432 KB
testcase_10 AC 390 ms
93,100 KB
testcase_11 AC 298 ms
90,064 KB
testcase_12 AC 340 ms
91,296 KB
testcase_13 AC 184 ms
90,676 KB
testcase_14 AC 93 ms
83,392 KB
testcase_15 AC 407 ms
95,020 KB
testcase_16 AC 316 ms
94,724 KB
testcase_17 AC 302 ms
89,552 KB
testcase_18 AC 135 ms
85,884 KB
testcase_19 AC 219 ms
91,844 KB
testcase_20 AC 218 ms
91,840 KB
testcase_21 AC 303 ms
91,468 KB
testcase_22 AC 428 ms
97,440 KB
testcase_23 AC 42 ms
55,736 KB
testcase_24 AC 42 ms
55,732 KB
testcase_25 AC 43 ms
55,736 KB
testcase_26 AC 46 ms
55,736 KB
testcase_27 AC 42 ms
55,736 KB
testcase_28 AC 42 ms
55,736 KB
testcase_29 AC 44 ms
55,736 KB
testcase_30 AC 42 ms
55,732 KB
testcase_31 AC 42 ms
55,736 KB
testcase_32 AC 43 ms
55,736 KB
testcase_33 AC 42 ms
55,736 KB
testcase_34 AC 42 ms
55,736 KB
testcase_35 AC 42 ms
55,736 KB
testcase_36 AC 42 ms
55,736 KB
testcase_37 AC 42 ms
55,736 KB
testcase_38 AC 42 ms
55,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from collections import deque

n,m=LI()
s,t,k=LI()
s,t=s-1,t-1
to=[[] for _ in range(n)]
for _ in range(m):
    u,v=LI1()
    to[u].append(v)
    to[v].append(u)

dist=[-1]*n
dist[s]=0
q=deque()
q.append(s)
while q:
    u=q.popleft()
    for v in to[u]:
        if dist[v]==-1:
            dist[v]=dist[u]+1
            q.append(v)

if n==1:
    print("No")
elif n==2 and s!=t and k&1==0:
    print("No")
elif dist[t]!=-1 and dist[t]&1==k&1 and dist[t]<=k and to[s]:
    print("Yes")
elif dist[t]!=-1 and dist[t]&1!=k&1:
    print("No")
else:
    print("Unknown")
0