結果
| 問題 |
No.2674 k-Walk on Bipartite
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-03-17 03:08:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,033 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 105,728 KB |
| 最終ジャッジ日時 | 2024-09-30 04:36:58 |
| 合計ジャッジ時間 | 5,323 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 12 |
ソースコード
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:
if (DIS[t]-k)%2==0:
print("Yes")
else:
print("No")
exit()
if DIS[t]>k:
if (DIS[t]-k)%2==0:
print("Unknown")
else:
print("No")
exit()
DIS=[-1]*N
Q=[t]
DIS[t]=0
LIST2=[]
while Q:
x=Q.pop()
LIST2.append(x)
for to in E[x]:
if DIS[to]==-1:
DIS[to]=DIS[x]+1
Q.append(to)
ELIST=0
for x in LIST:
ELIST+=len(E[x])
ELIST2=0
for x in LIST2:
ELIST2+=len(E[x])
if ELIST==len(LIST)*(len(LIST)-1):
print("No")
elif ELIST2==len(LIST2)*(len(LIST2)-1):
print("No")
else:
print("Yes")
titia