题意:
输入一个正整数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 分)的更多相关文章

  1. PAT 甲级 1064 Complete Binary Search Tree (30 分)(不会做,重点复习,模拟中序遍历)

    1064 Complete Binary Search Tree (30 分)   A Binary Search Tree (BST) is recursively defined as a bin ...

  2. pat 甲级 1064. Complete Binary Search Tree (30)

    1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  3. PAT甲级:1064 Complete Binary Search Tree (30分)

    PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...

  4. pat 甲级 1064 ( Complete Binary Search Tree ) (数据结构)

    1064 Complete Binary Search Tree (30 分) A Binary Search Tree (BST) is recursively defined as a binar ...

  5. PAT 甲级 1064 Complete Binary Search Tree

    https://pintia.cn/problem-sets/994805342720868352/problems/994805407749357568 A Binary Search Tree ( ...

  6. 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 ...

  7. 1064 Complete Binary Search Tree (30分)(已知中序输出层序遍历)

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...

  8. PAT题库-1064. Complete Binary Search Tree (30)

    1064. Complete Binary Search Tree (30) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  9. 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 ...

随机推荐

  1. python正则分组

    python的正则表达式本身每一个字符串都是独立的 看下面的例子就理解分组的含义了~ ab*表示的是查找a和(0个或多个b),就是*是单独针对b的,所以返回a (ab)*则表示ab是一个组是一个整体, ...

  2. VUE常用写法

    v-for: v-for ='item,key of data' v-for ='item,index in data'     @click='' @click='pop.show=false'   ...

  3. C#系统库的源代码

    .NET Core:https://github.com/dotnet/corefx .NET Framework:https://referencesource.microsoft.com

  4. ACM的探索之Keen On Evrything But Triangle(我觉得可以很接近啦!!)

    #include<bits/stdc++.h> using namespace std; int main() { int n,q,l,r; while(cin>>n>& ...

  5. 如何创建Maven项目和Spring IOC例子

    把如何创建Maven项目和创建Spring IOC的例子分享给大家,希望能对大家有帮助! 我的博客地址:https://www.cnblogs.com/themysteryofhackers/p/12 ...

  6. Python格式化字符串知多少

    字符串格式化相当于字符串模板.也就是说,如果一个字符串有一部分是固定的,而另一部分是动态变化的,那么就可以将固定的部分做成模板,然后那些动态变化的部分使用字符串格式化操作符(%) 替换.如一句问候语: ...

  7. HGAME 2020 week1 web

    1.Cosmos 的博客 知识点:git source code leak 2.接 头 霸 王 Description HGAME Re:Dive 开服啦~ 打开题目,提示了"头" ...

  8. C:指针基础

    内存概述 内存 内存含义: 存储器:计算机的组成中,用来存储程序和数据,辅助CPU进行运算处理的重要部分. 内存:内部存贮器,暂存程序/数据--掉电丢失 SRAM.DRAM.DDR.DDR2.DDR3 ...

  9. netty(二)---客户端连接

    概述 先了解一下 netty 大概框架图 ,可以看到客户端的创建和服务端最大的区别 - 服务端传入两个 EventLoopGroup,客户端传入一个 EventLoopGroup - channel ...

  10. oracle 密码过期问题

     密码过期问题: ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;