結果
問題 | No.1465 Archaea |
ユーザー |
|
提出日時 | 2021-04-02 22:02:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 2,067 ms |
コンパイル使用メモリ | 197,636 KB |
最終ジャッジ日時 | 2025-01-20 09:18:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define ALL(x) ::std::begin(x), ::std::end(x) using namespace std; template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >; bool solve(int n, int k) { vector<int> dist(n + 1, INT_MAX); queue<int> que; auto push = [&](int x, int dist_x) { if (n < x) return; if (dist[x] <= dist_x) return; dist[x] = dist_x; que.push(x); }; push(1, 0); while (not que.empty()) { int x = que.front(); que.pop(); push(2 * x, dist[x] + 1); push(x + 3, dist[x] + 1); } return dist[n] <= k; } // generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator) const string YES = "YES"; const string NO = "NO"; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); constexpr char endl = '\n'; int N, K; cin >> N >> K; auto ans = solve(N, K); cout << (ans ? YES : NO) << endl; return 0; }