結果

問題 No.1465 Archaea
ユーザー rrtarrta
提出日時 2021-04-05 02:17:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 173,048 KB
実行使用メモリ 15,768 KB
最終ジャッジ日時 2023-08-28 13:39:49
合計ジャッジ時間 3,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 8 ms
6,064 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 10 ms
7,716 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 9 ms
6,992 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 19 ms
12,484 KB
testcase_14 AC 9 ms
6,976 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 20 ms
12,928 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 11 ms
7,464 KB
testcase_20 AC 16 ms
10,376 KB
testcase_21 AC 25 ms
15,768 KB
testcase_22 AC 26 ms
15,684 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll INF=1000000000000000;
using Graph=vector<vector<ll>>;
ll N,K;
ll d[200005];
void bfs(const Graph &G,ll s){
fill(d,d+N+1,INF);d[s]=0;
  queue<ll>que;que.push(s);
  while(!que.empty()){
  ll v=que.front();que.pop();
    for(auto u:G[v]){
    if(d[u]!=INF)continue;
      d[u]=d[v]+1;que.push(u);
    }
  }
}
int main(){
 cin>>N>>K;
  Graph G(N+1);if(2<=N)G[2].push_back(1);
  for(ll i=3;i<=N;i++){
  G[i].push_back(i-3);
    if(i%2==0)G[i].push_back(i/2);
  }bfs(G,N);
  if(d[1]<=K)cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}
0