結果
| 問題 | 
                            No.642 Two Operations No.1
                             | 
                    
| コンテスト | |
| ユーザー | 
                             uw_yu1rabbit
                         | 
                    
| 提出日時 | 2020-09-03 14:55:41 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 805 bytes | 
| コンパイル時間 | 3,380 ms | 
| コンパイル使用メモリ | 103,900 KB | 
| 最終ジャッジ日時 | 2025-01-14 04:11:05 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 TLE * 2 MLE * 11 | 
コンパイルメッセージ
main.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main(){
      | ^~~~
            
            ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<map>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
map<i64,i64>mp;
i64 n;
void dfs(i64 x,i64 cnt){
    if(x != 1 && mp[x] != 0 && mp[x] < cnt){
        return;
    }else if(x == n){
        mp[x] = cnt;
        return ;
    }else if(x < 1){
        return ;
    }else if(x > 2 * n){
        return ;
    }
    mp[x] = cnt;
    dfs(2 * x,cnt + 1);
    dfs(x - 1,cnt + 1);
    return ;
}
main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cin >> n;
dfs((i64)(1),(i64)(0));
cout << mp[n] << endl;
}
            
            
            
        
            
uw_yu1rabbit