結果
問題 | No.566 だいたい完全二分木 |
ユーザー | dnish |
提出日時 | 2018-06-17 11:53:12 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 1,510 ms |
コンパイル使用メモリ | 168,212 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-13 06:19:07 |
合計ジャッジ時間 | 2,607 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
ソースコード
#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<<endl #define p2(a,b) cout<<(a)<<" "<<(b)<<endl typedef long long ll; using namespace std; const ll inf=1e18; vector<int> ans; void f(int L, int R) { if (L == 1 && R == 2) { ans.push_back(1); ans.push_back(2); return; } if (L == R) { ans.push_back(L); return; } int md = (L + R) / 2; ans.push_back(md); f(L, md - 1); f(md + 1, R); } int main(){ int K; cin>>K; int node=1; REP(i,0,K){ node*=2; } f(1,node-2); cout<<node-1; REP(i,0,ans.size()){ cout<<" "<<ans[i]; } cout<<endl; return 0; }