博客
关于我
洛谷P1377树的序
阅读量:340 次
发布时间:2019-03-04

本文共 505 字,大约阅读时间需要 1 分钟。

洛谷P1377树的序

思路

4个数组保存一棵树

2个保存左右儿子
1个保存值
1个保存指针

CODE

#include
#include
#include
using namespace std;int a[100010][4];void DFS(int x){ if(x==0)return; cout<
<<' '; if(a[x][2])DFS(a[x][2]); if(a[x][3])DFS(a[x][3]); return;}int main(){ ios::sync_with_stdio(false); int i,n,len=0,tem; memset(a,0,sizeof(a)); for(cin>>n,i=1; i<=n; i++)cin>>tem,a[tem][0]=i; for(i=1; i<=n; i++) { for(tem=len;tem&&a[a[tem][1]][0]>a[i][0];tem--); if(tem)a[a[tem][1]][3]=i; if(tem

转载地址:http://wrze.baihongyu.com/

你可能感兴趣的文章
Mysql性能优化(3):分析执行计划
查看>>
Mysql性能优化(4):优化的注意事项
查看>>
Mysql性能优化(5):主从同步原理与实现
查看>>
Mysql性能优化(6):读写分离
查看>>
MySQL性能优化(八)--
查看>>
MySQL性能测试及调优中的死锁处理方法
查看>>
mysql性能测试工具选择 mysql软件测试
查看>>
mysql恢复root密码
查看>>
Mysql悲观锁
查看>>
MySQL慢查询-开启慢查询
查看>>
MySQL慢查询分析和性能优化的方法和技巧
查看>>
MySQL慢查询日志总结
查看>>
Mysql慢查询日志,查询截取分析
查看>>
MySQL慢查询问题排查
查看>>
mysql截取sql语句
查看>>
mysql截取身份证号前几位_EXCEL中怎样截取身份证号前六位数字
查看>>
mysql手工注入
查看>>
MySQL执行SQL文件出现【Unknown collation ‘utf8mb4_0900_ai_ci‘】的解决方案
查看>>
Mysql执行update by id的过程
查看>>
mysql执行计划
查看>>