結果

問題 No.566 だいたい完全二分木
ユーザー snrnsidy
提出日時 2025-09-14 23:54:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 194,492 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-14 23:54:45
合計ジャッジ時間 2,655 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void solve(int l,int r)
{
    if(l==r)
    {
        cout << l << ' ';
        return;
    }
    else if(l > r)
    {
        return;
    }
    int m = (l+r)/2;
    cout << m << ' ';
    solve(l,m-1);
    solve(m+1,r);
    return;
}
int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;
    cin >> n;

    solve(1,(1<<n)-2);
    cout << (1<<n) - 1 << '\n';


	return 0;
}
0