結果

問題 No.1465 Archaea
ユーザー Hydrogen332
提出日時 2025-08-17 01:36:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 3,160 ms
コンパイル使用メモリ 281,524 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-17 01:36:49
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;
    
    vector<int> dist(N + 1, -1);
    queue<int> que;
    dist[1] = 0;
    que.push(1);
    
    while (!que.empty()) {
        int M = que.front();
        que.pop();
        
        if (2 * M <= N) {
            if (dist[2 * M] == -1) {
                dist[2 * M] = dist[M] + 1;
                que.push(2 * M);
            }
        }
        
        if (M + 3 <= N) {
            if (dist[M + 3] == -1) {
                dist[M + 3] = dist[M] + 1;
                que.push(M + 3);
            }
        }
    }
    
    if (dist[N] == -1 || dist[N] > K) cout << "NO\n";
    else cout << "YES\n";
}
0