結果
| 問題 |
No.3291 K-step Navigation
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-10-09 02:12:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 301 ms / 3,000 ms |
| コード長 | 1,120 bytes |
| コンパイル時間 | 317 ms |
| コンパイル使用メモリ | 82,400 KB |
| 実行使用メモリ | 77,576 KB |
| 最終ジャッジ日時 | 2025-10-09 02:12:30 |
| 合計ジャッジ時間 | 6,789 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 51 |
ソースコード
import sys
input = sys.stdin.readline
from collections import deque
N,M,K,s,t=map(int,input().split())
E=[[] for i in range(N+1)]
for i in range(M):
x,y=map(int,input().split())
E[x].append(y)
E[y].append(x)
if K%2==1:
print("Yes")
exit()
if E[s]==[] and E[t]==[]:
print("No")
exit()
if len(E[s])==1 and len(E[t])==1 and E[s][0]==t:
MAX=1<<63
for i in range(1,N+1):
Q=deque()
Q.append((-1,i))
USE=[-1]*(N+1)
USE[i]=0
while Q:
fr,x=Q.popleft()
for to in E[x]:
if to==fr:
continue
if USE[to]==-1:
USE[to]=USE[x]+1
Q.append((x,to))
continue
if USE[to]%2!=USE[x]%2:
continue
else:
#print(i,to,MAX)
MAX=min(MAX,USE[to]+USE[x]+1)
if K>=MAX+3:
print("Yes")
exit()
if K%2==1:
print("Yes")
else:
print("No")
exit()
print("Yes")
titia