結果
| 問題 | No.1465 Archaea | 
| コンテスト | |
| ユーザー |  hiraku | 
| 提出日時 | 2021-04-03 09:44:03 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 945 bytes | 
| コンパイル時間 | 340 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 26,624 KB | 
| 最終ジャッジ日時 | 2024-12-24 12:31:21 | 
| 合計ジャッジ時間 | 2,335 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 4 | 
| other | RE * 20 | 
ソースコード
from collections import deque
def bfs(start, goal):
    """[summary]
    dfs: stack, pop()
    bfs: queue, popleft()
    Parameters
    ----------
    start : [int]
        [description]
    goal : [int]
        [description]
    """
    queue = deque()
    for i, dim in graph[start][0]:
        queue.append((i))
        visited[i] = 1
    while queue:
        q, d = queue.popleft()
        # ゴールの条件(無くても良い)
        # if q == goal and d == 0:
        #   return
        dist = visited[q]
        for i, di in graph[q][d]:
            if visited[i] > dist + 1:
                queue.append((i, di))
                visited[i] = dist + 1
n, k = map(int, input().split())
graph = [list() for _ in range(n + 1)]
INF = 10 ** 9
visited = [INF] * (n + 1) 
for i in range(1, n) + 1:
  graph[i].append(i + 3)
  graph[i].append(i * 2)
bfs(1, n)
ans = visited[n]
if ans == INF or ans > k:
  print("NO")
else:
  print("YES")
            
            
            
        