結果

問題 No.1465 Archaea
コンテスト
ユーザー jebouin
提出日時 2021-04-02 22:04:17
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,508 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,081 ms
コンパイル使用メモリ 189,456 KB
実行使用メモリ 244,480 KB
最終ジャッジ日時 2026-10-15 06:01:19
合計ジャッジ時間 8,128 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
set<pair<int, int>> st;
int n, k;

bool solve(int k, int x) {
    if(x == 1) {
        return true;
    }
    if(k == 0) {
        return false;
    }
    if(st.find(make_pair(k, x)) != st.end()) {
        return false;
    }
    st.insert({k, x});
    if(x % 2 == 0 && solve(k - 1, x / 2)) {
        return true;
    }
    if(solve(k - 1, x - 3)) {
        return true;
    }
    return false;
}

int solve() {
    cin >> n >> k;
    bool ans = solve(k, n);
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}
0