[TIOJ] 1609. Problem C 二元搜尋樹 (TRVBST)

題目連結:http://tioj.infor.org/problems/1609
其實一棵二元搜尋樹中序遍歷就是大小關係,所以直接把他給你的數字由小到大sort過一遍後印出來就是答案了
#include <bits/stdc++.h>
using namespace std;

int arr[1000005];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;i++)cout<<arr[i]<<' ';
	return 0;
}

留言

這個網誌中的熱門文章

[TIOJ] 1902. 「殿仁.王,不認識,誰啊?」,然後他就死了……

[AtCoder] [經典競程 90 題] 024 - Select +/- One(★2)

[AtCoder] [經典競程 90 題] 022 - Cubic Cake(★2)