結果

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

ソースコード

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;

    if(n<=3)
    {
        for(int i=0;i<(1<<n)-1;i++)
        {
            cout << i+1 << ' ';
        }
        cout << '\n';
    }
    else
    {
        solve(1,(1<<n)-1);
        cout << '\n';
    }

	return 0;
}
0