結果
| 問題 | No.1465 Archaea | 
| コンテスト | |
| ユーザー |  Kiri8128 | 
| 提出日時 | 2021-04-02 21:55:10 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 69 ms / 2,000 ms | 
| コード長 | 536 bytes | 
| コンパイル時間 | 316 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 67,840 KB | 
| 最終ジャッジ日時 | 2024-12-24 01:17:00 | 
| 合計ジャッジ時間 | 2,657 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 20 | 
ソースコード
from collections import deque
N, K = map(int, input().split())
def BFS_dist(n, i0=0):
    Q = deque([i0])
    D = [-1] * n
    D[i0] = 0
    while Q:
        x = Q.popleft()
        if x % 2 == 0:
            c = x // 2
            if c > 0 and D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
        if x - 3 > 0:
            c = x - 3
            if c > 0 and D[c] == -1:
                D[c] = D[x] + 1
                Q.append(c)
    return D
D = BFS_dist(N + 1, N)
print("YES" if 0 <= D[1] <= K else "NO")
            
            
            
        