結果

問題 No.566 だいたい完全二分木
ユーザー CleyLCleyL
提出日時 2022-09-22 10:21:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 73,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 20:26:23
合計ジャッジ時間 2,953 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
vector<int> A;
int x;
void solve(int a,int b){
    if(x != a+1)A.push_back(a+1);
    if(b!=1){
        solve(a-b/2,b/2);
        solve(a+b/2,b/2);
    }
}
int main(){
    int n;cin>>n;
    x = (1<<(n-1));
    solve((1<<(n-2)),(1<<(n-2)));
    for(int i = 0; A.size() > i; i++){
        cout << A[i] << " ";
    }
    cout << 1 << endl;
}
0