洛谷P1030 [NOIP 2001 普及组] 求先序排列
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
void f(string s1,string s2){
	if(s1.size()<=0)return;
	cout<<s2[s2.size()-1];
	int flag;
	for(int i=0;i<s1.size();i++){
		if(s1[i]==s2[s2.size()-1]){
			flag=i;break;
		}
	}
	f(s1.substr(0,flag),s2.substr(0,flag));
	f(s1.substr(flag+1,s1.size()-flag-1),s2.substr(flag,s1.size()-flag-1));
}
int main() {
	cin>>s1>>s2;
	f(s1,s2);
 	return 0;
}
已知前序或后序任一再加上中序可确定一棵二叉树
通过前/后序找出根,再根据该根和中序确定该根的两棵子树,不断递推可得到确定二叉树

评论

  1. 1 月前
    2026-2-21 8:17:49

    Want to win? 9winbet caught my attention. I had a good run with them. Give it a try 9winbet, you might just get lucky!

  2. 1 月前
    2026-2-21 8:18:07

    Taigoo88, eh? It’s got a nice interface and seems like a decent place to play. I tried only a few games here, all smooth. Give it a try, you might like it. Here’s a link: taigoo88

  3. 1 月前
    2026-2-21 8:18:23

    Alright, v88bet has been around for a bit. Lots of game choices. Payouts are reliable so far. Check it out and let me know what you think! Go for: v88bet

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇