結果

問題 No.2674 k-Walk on Bipartite
ユーザー miho-4miho-4
提出日時 2024-03-15 22:36:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 111,692 KB
最終ジャッジ日時 2024-03-15 22:36:13
合計ジャッジ時間 6,934 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,472 KB
testcase_01 AC 41 ms
55,472 KB
testcase_02 AC 41 ms
55,472 KB
testcase_03 AC 43 ms
55,472 KB
testcase_04 AC 41 ms
55,472 KB
testcase_05 AC 41 ms
55,472 KB
testcase_06 AC 41 ms
55,472 KB
testcase_07 AC 283 ms
104,756 KB
testcase_08 AC 317 ms
104,420 KB
testcase_09 AC 192 ms
96,096 KB
testcase_10 AC 364 ms
111,692 KB
testcase_11 AC 302 ms
101,188 KB
testcase_12 AC 313 ms
102,960 KB
testcase_13 AC 194 ms
98,624 KB
testcase_14 AC 109 ms
86,056 KB
testcase_15 AC 373 ms
106,528 KB
testcase_16 AC 302 ms
107,836 KB
testcase_17 AC 292 ms
104,492 KB
testcase_18 AC 148 ms
90,932 KB
testcase_19 AC 200 ms
95,364 KB
testcase_20 AC 179 ms
92,792 KB
testcase_21 AC 335 ms
105,312 KB
testcase_22 AC 385 ms
108,692 KB
testcase_23 AC 43 ms
55,472 KB
testcase_24 AC 42 ms
55,472 KB
testcase_25 AC 43 ms
55,472 KB
testcase_26 AC 41 ms
55,472 KB
testcase_27 AC 42 ms
55,472 KB
testcase_28 AC 42 ms
55,472 KB
testcase_29 AC 41 ms
55,472 KB
testcase_30 AC 43 ms
55,472 KB
testcase_31 AC 41 ms
55,472 KB
testcase_32 AC 41 ms
55,472 KB
testcase_33 AC 43 ms
55,472 KB
testcase_34 AC 41 ms
55,472 KB
testcase_35 AC 41 ms
55,472 KB
testcase_36 AC 42 ms
55,472 KB
testcase_37 AC 41 ms
55,472 KB
testcase_38 AC 42 ms
55,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,m=map(int,input().split())
s,t,k=map(int,input().split())
edge=[list(map(int,input().split())) for _ in range(m)]

E=[[] for _ in range(n+1)]
for u,v in edge:
  E[v].append(u)
  E[u].append(v)
  
D=[10**9]*(n+1)
P=[-1]*(n+1)
D[s],P[s]=0,0
q=deque([(s)])
while q:
  x=q.popleft()
  for e in E[x]:
    if D[x]+1<D[e]:
      P[e]=P[x]^1
      D[e]=D[x]+1
      q.append(e)
if n==1:exit(print("No"))
if s==t:
  if k%2==1:exit(print("No"))
  if 1<=len(E[s]):
    exit(print("Yes"))
  else:
    exit(print("Unknown"))

if P[t]==0:
  if k%2==1:
    print("No")
  else:
    if D[t]<=k:
      print("Yes")
    else:
      print("Unknown")
elif P[t]==1:
  if k%2==0:
    print("No")
  else:
    if D[t]<=k:
      print("Yes")
    else:
      print("Unknown")
else:
  if n==1:print("No")
  elif n==2:
    if s==t:
      if k%2==1:print("No")
      else:print("Unknown")
    else:#s!=t
      if k%2==0:print("No")
      else:print("Unknown")
  else:
    print("Unknown")
0