当前位置:网站首页>1064 Complete Binary Search Tree (30 分)
1064 Complete Binary Search Tree (30 分)
2022-07-22 10:33:00 【学编程的蒟蒻】
1064 Complete Binary Search Tree (30 分)
#include <iostream>
#include <algorithm>
using namespace std;
int a[1050], tree[1050], n, ret;
void dfs(int root){
if(root > n)
return;
dfs(root * 2);
tree[root] = a[ret++];
dfs(root * 2 + 1);
}
int main() {
cin >> n;
for(int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a + n);
dfs(1);
for(int i = 1; i <= n; ++i)
cout << tree[i] << " \n"[i == n];
}
边栏推荐
- LeetCode0003——longest substring without repeating characters——Sliding Window
- CSDN博客去除上传的图片水印
- LeetCode160 & LeetCode141——double pointers to solve the linked list
- sql优化技巧及注意事项
- LeetCode0003——longest substring without repeating characters——Sliding Window
- 《强化学习周刊》第39期:近似最优深度、多智能体广义、角色动画强化学习
- Kubernetes基础
- Her power series five Zhu Haiyi: people oriented, building AI values
- 1049 Counting Ones (30 分)
- What is network hijacking? How to repair web pages that have been tampered with and hijacked (final scheme) how to repair web page hijacking?
猜你喜欢
Core concepts of elastic search learning Introduction (4)
信号降噪方法
Leetcode0002——Add Two Numbers——Linked List
Chinese search for introduction to elastic search (8)
她力量系列二丨UCLA李婧翌:女性最不需要做的就是「怀疑自己」
What should I do after the domain name of website security is hijacked and the domain name is hijacked!!!
Dense passage retrieval for open domain question answering notes
What is the meaning of DNS hijacking, the principle of DNS hijacking and several solutions
信号量实现同步互斥经典案例
Introduction to machine learning: support vector machine-6
随机推荐
正则表达式学习笔记
How to prevent DNS hijacking and what is DNS? DNS hijacking details
linux Redis下载及安装
SSM framework integration
深入理解mmap函数
How to repair DNS hijacking perfectly? How to solve DNS hijacking and how to repair it perfectly
JDBC异常SQLException的捕获与处理
Don't hack the website. How to solve it? How to deal with the problem of website being hacked
机器学习入门:逻辑回归-2
Mysql连接失败解决方案
Exclusive interview with Huang Hui, a scholar of women in AI: dream of drawing shapes and find the door to breakthrough
Redis accesses JSON data
1080 Graduate Admission (30 分)
数据从一台Mysql传输到另一台Mysql
RP file Chrome browser view plug-in
生成删除数据库所有表的外检脚本
Leetcode206 - reverse linked list
redission扣库存demo
Leetcode0022 - bracket generation - DFS
Unix C语言 POSIX 互斥锁 线程同步