博客
关于我
洛谷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数据碎片整理
查看>>
MySQL数据类型
查看>>
MySQL数据类型字节长度
查看>>
mysql数据被误删的恢复方案
查看>>
MySQL数据读写分离(MaxScale)上干货!!!
查看>>
mysql整库导入、导出
查看>>
mysql文本函数和数字函数
查看>>
Mysql新建用户和数据库并授权
查看>>
mysql日志
查看>>
mysql日志 事务问题_mysql因为事务日志问题无法启动
查看>>
mysql日志文件
查看>>
mysql日志管理学习笔记
查看>>
mysql日志问题定位实用命令
查看>>
MySQL日期时间函数大全
查看>>
mysql时间相减的问题
查看>>