結果

問題 No.1465 Archaea
コンテスト
ユーザー tabae326
提出日時 2021-04-02 22:26:45
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,404 ms
コンパイル使用メモリ 216,756 KB
実行使用メモリ 494,828 KB
最終ジャッジ日時 2026-06-19 10:36:14
合計ジャッジ時間 5,420 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 1 WA * 2 TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

void solve() {
    ll n, k;
    cin >> n >> k;
    const ll inf = 1e18;
    vector<ll> d(n+1, inf);
    using pl = pair<ll,ll>;
    queue<pl> que;
    que.push({n, 0});
    while(!que.empty()) {
        auto [m, cnt] = que.front();
        que.pop();
        if(cnt == k) {
            if(m == 1) {
                cout << "YES\n";
                return;
            }
        } else {
            if(m - 3 * (k - cnt) < 1) continue;
            if(m % 2 == 0 && m / 2 >= 1) que.push({m / 2, cnt + 1});
            if(m - 3 >= 1) que.push({m - 3, cnt + 1});
        }
    }
    cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0