結果

問題 No.1010 折って重ねて
ユーザー t98slider
提出日時 2023-01-19 09:46:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 174,736 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 23:02:11
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, y, h;
    cin >> x >> y >> h;
    set<pair<ll,ll>> S;
    function<ll(ll,ll,ll)> dfs = [&](ll x, ll y, ll h){
        if(S.count(make_pair(x, y)))return 0ll;
        S.insert(make_pair(x, y));
        ll res = 0;
        if(x > h)res = max(res, dfs(x, y * 2, h * 4) + 1);
        if(y > h)res = max(res, dfs(x * 2, y, h * 4) + 1);
        return res;
    };
    cout << dfs(x * 1000, y * 1000, h) << '\n';
}
0