結果

問題 No.1465 Archaea
ユーザー tabae326tabae326
提出日時 2021-04-02 22:27:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 5,267 ms
コンパイル使用メモリ 204,496 KB
実行使用メモリ 302,780 KB
最終ジャッジ日時 2023-08-25 12:38:31
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) < -100) 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