結果

問題 No.1465 Archaea
ユーザー flippergo
提出日時 2025-04-16 21:32:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 81,940 KB
実行使用メモリ 110,016 KB
最終ジャッジ日時 2025-04-16 21:32:48
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
from collections import deque
N,K = map(int,input().split())
Visited = [0]*(N+1)
Visited[1] = 0
que = [1]
G = {1:[]}
while que:
    x = heapq.heappop(que)
    if Visited[x]==1:continue
    Visited[x] = 1
    y = 2*x
    if y<=N and Visited[y]==0:
        heapq.heappush(que,y)
        G[y] = []
        G[x].append(y)
    y = x+3
    if y<=N and Visited[y]==0:
        heapq.heappush(que,y)
        G[y] = []
        G[x].append(y)
dist = [-1]*(N+1)
dist[1] = 0
que = deque([1])
while que:
    x = que.popleft()
    for y in G[x]:
        if dist[y]==-1:
            dist[y] = dist[x]+1
            que.append(y)
if dist[N]==-1 or dist[N]>K:
    print("NO")
else:
    print("YES")
0