結果

問題 No.1465 Archaea
ユーザー milanis48663220milanis48663220
提出日時 2021-04-02 21:52:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,473 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 103,772 KB
実行使用メモリ 15,212 KB
最終ジャッジ日時 2023-08-25 16:12:57
合計ジャッジ時間 2,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 9 ms
6,224 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 14 ms
7,692 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 12 ms
7,004 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 29 ms
12,304 KB
testcase_14 AC 12 ms
7,216 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 29 ms
12,840 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 12 ms
7,480 KB
testcase_20 AC 20 ms
10,220 KB
testcase_21 AC 36 ms
15,212 KB
testcase_22 AC 35 ms
15,168 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;
const int INF = 1e9;
using P = pair<int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, k; cin >> n >> k;
    vector<vector<int>> g(n+1);
    auto add_edge = [&](int i, int j){
        if(i <= n && j <= n){
            g[i].push_back(j);
        }
    };
    for(int i = 1; i <= n; i++){
        add_edge(i, 2*i);  
        add_edge(i, i+3);
    }
    vector<int> dist(n+1, INF);
    dist[1] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 1));
    while(!que.empty()){
        auto [d, v] = que.top(); que.pop();
        if(dist[v] != d) continue;
        for(int to : g[v]){
            if(dist[to] > d+1){
                dist[to] = d+1;
                que.push(P(d+1, to));
            }
        }
    }
    if(dist[n] <= k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
0