当前位置:网站首页>1086 tree traversals again (25 points)
1086 tree traversals again (25 points)
2022-07-03 04:56:00 【vs5】
Stacking is the preamble , Out of the stack is the middle order
#include <iostream>
#include <vector>
using namespace std;
const int N = 50;
int stk[N],top,f;
vector<int>pre,in;
// Stacking is the preamble , Out of the stack is the middle order
void dfs(int preL,int preR,int inL,int inR)
{
if(preL > preR) return ;
int k = inL;
while(in[k] != pre[preL]) k ++;
dfs(preL + 1,preL + k - inL,inL,k - 1);
dfs(preL + 1 + k - inL,preR,k + 1,inR);
if(f != 0) cout << ' ';
cout << pre[preL];f = 1;
}
int main()
{
int n,x,cnt = 0;
string s;
cin >> n;
while(cnt != n)
{
cin >> s;
if(s[1] == 'u')
{
cin >> x;
stk[ ++ top] = x;
pre.push_back(x);
}
else in.push_back(stk[top --]),cnt ++;
}
dfs(0,n - 1,0,n - 1);
return 0;
} 边栏推荐
- Blog building tool recommendation (text book delivery)
- Notes | numpy-09 Broadcast
- The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
- 论文阅读_清华ERNIE
- Market status and development prospect forecast of global button dropper industry in 2022
- JDBC database operation
- Sprintf formatter abnormal exit problem
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- stm32逆向入门
- Keepalived热备与HAProxy
猜你喜欢

论文阅读_ICD编码_MSMN

Introduction to JVM principle

Shuttle + alluxio accelerated memory shuffle take-off

M1 Pro install redis

Thesis reading_ Chinese medical model_ eHealth
![[research materials] 2022q1 game preferred casual game distribution circular - Download attached](/img/13/5a67c5d08131745759fdc70a71cf0f.jpg)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached

【工具跑SQL盲注】
![[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa](/img/a9/92059db74ccde03b84c69dfce35b37.jpg)
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa

Three representations of signed numbers: original code, inverse code and complement code

Preparation for school and professional cognition
随机推荐
Objects. Requirenonnull method description
Sprintf formatter abnormal exit problem
Basic use of Metasploit penetration testing framework
Market status and development prospect forecast of global button dropper industry in 2022
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
Notes | numpy-09 Broadcast
5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
Market status and development prospect prediction of the near infrared sensor industry of the global Internet of things in 2022
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
Actual combat 8051 drives 8-bit nixie tube
Valentine's day limited withdrawal guide: for one in 200 million of you
【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
Introduction to message queuing (MQ)
[tools run SQL blind note]
Games101 Lesson 9 shading 3 Notes
UiPath实战(08) - 选取器(Selector)
Cross platform plug-in flutter for displaying local notifications_ local_ notifications