题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=202
思路:balabala说了一大堆和红黑树的东西,其实做题的时候和红黑树卵关系没有,因为,二叉树的旋转是不改变中序遍历的2333333
#include<bits/stdc++.h>
using namespace std;
void read() {
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
}
struct Node {
int l;
int r;
}node[11];
void f(int x) {
if(x==-1) return;
f(node[x].l);
cout << x << endl;
f(node[x].r);
}
int main() {
//read();
int t,n;
cin >> t;
while(t--) {
cin >> n;
int m;
for(int i = 0; i < n; i++) {
cin >> m;
cin >> node[m].l >> node[m].r;
}
int num,x,y;
cin >> num;
while(num--) cin >> x >> y;
f(0);
}
return 0;
}