【PAT甲级】1064 Complete Binary Search Tree (30 分)
题意:
输入一个正整数N(<=1000),接着输入N个非负整数(<=2000),输出完全二叉树的层次遍历。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[];
int tree[];
int cnt;
int n;
void dfs(int x){
if(x>n)
return;
dfs(x*);
tree[x]=a[++cnt];
dfs(x*+);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=;i<=n;++i)
cin>>a[i];
sort(a+,a++n);
dfs();
cout<<tree[];
for(int i=;i<=n;++i)
cout<<" "<<tree[i];
return ;
}
【PAT甲级】1064 Complete Binary Search Tree (30 分)的更多相关文章
- PAT 甲级 1064 Complete Binary Search Tree (30 分)(不会做,重点复习,模拟中序遍历)
1064 Complete Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a bin ...
- pat 甲级 1064. Complete Binary Search Tree (30)
1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- PAT甲级:1064 Complete Binary Search Tree (30分)
PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...
- pat 甲级 1064 ( Complete Binary Search Tree ) (数据结构)
1064 Complete Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a binar ...
- PAT 甲级 1064 Complete Binary Search Tree
https://pintia.cn/problem-sets/994805342720868352/problems/994805407749357568 A Binary Search Tree ( ...
- PAT Advanced 1064 Complete Binary Search Tree (30) [⼆叉查找树BST]
题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following proper ...
- 1064 Complete Binary Search Tree (30分)(已知中序输出层序遍历)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...
- PAT题库-1064. Complete Binary Search Tree (30)
1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- 1064. Complete Binary Search Tree (30)【二叉树】——PAT (Advanced Level) Practise
题目信息 1064. Complete Binary Search Tree (30) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B A Binary Search Tr ...
随机推荐
- 搭建FEBS权限系统
在码云看到一个FEBS权限系统,但是没有找到搭建手册,自己记录一下. 1.下载项目:https://github.com/wuyouzhuguli/FEBS-Shiro2.创建数据库:执行sql文件夹 ...
- Visual Studio 2017:SQLite/SQL Server Compact ToolBox使用
1.首先是下载安装插件:SQLite/SQL Server Compact Toolbox,也可以从工具-->扩展和更新-->联机-->搜索:SQLite/SQL Server Co ...
- 公有IP和私有IP的区别
什么是IP? 在网络中,每台计算机都有一个唯一的地址,方便别人找到它,这个地址称为IP地址 IP地址是一个网络编码,用来确定网络中的一个节点,是由32位的二进制组成 IP地址的组成? IP地址由网络部 ...
- SQL Server 用户定义表类型
用户定义表类型: CREATE TYPE [dbo].[TVP_Location] AS TABLE( [Location] [varchar](50) NOT NULL, [Address] [va ...
- 「题解」「CF468D」树中的配对
目录 题目大意 思路 源代码 本博客除代码之外,来自 skylee 大佬. 题目大意 一棵\(n(n\le10^5)\)个编号为\(1\sim n\)的点的带边权的树,求一个排列\(p_{1\sim ...
- git 本地回滚与远程库回滚
不说废话,开始: 一.本地回滚: git reset --hard commit-id //回滚到commit-id 二.远程回滚操作分3步:①将本地分支退回到某个commit ②删除远程分支 ...
- etc/hosts文件详解
Linux 修改 etc/hosts文件 hosts文件 hosts —— the static table lookup for host name(主机名查询静态表). hosts文件是Linux ...
- 无法创建“System.Object”类型的常量值。此上下文仅支持基元类型或枚举类型
Entity FreamWork 无法创建“System.Object”类型的常量值.此上下文仅支持基元类型或枚举类型错误解决: 最近在开发中把我原来抄的架构里面的主键由固定的Guid改成了可以泛型指 ...
- cpu io disk mem监控 python
import psutil def cpu_information(): #scputimes(user=26.9, nice=0.1, system=50.27, idle=8551.89, iow ...
- CentOS6.5_x64安装MySQL-5.6.17,在已经启动MySQL服务的情况下,出现密码报错ERROR 2002 (HY000)
1.修改MySQL配置文件,使MySQL登陆时跳过密码验证 skip-grant-tables 2.重启MySQL服务 service mysql restart 3.进入MySQL,修改user表中 ...