結果
| 問題 |
No.566 だいたい完全二分木
|
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-09-08 22:53:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 804 bytes |
| コンパイル時間 | 965 ms |
| コンパイル使用メモリ | 91,396 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 05:49:17 |
| 合計ジャッジ時間 | 1,648 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
vector<int> x;
void dfs(int l, int r) {
int cen = (r + l) / 2;
x.push_back(cen);
if(l == r) return;
dfs(l,cen-1);
dfs(cen+1,r);
}
int main()
{
int K; cin >> K;
int n = pow(2, K) - 1;
dfs(1, n);
FOR(i,0,n) {
if(x[i] == n) cout << x[i] - 1;
else if(x[i] == n - 1) cout << x[i] + 1;
else cout << x[i];
if(i != n - 1) cout << " ";
}
cout << endl;
return 0;
}
nenuon