阿巴阿巴

枫原万叶  •  1个月前


include <bits/stdc++.h>

define M 500010

using namespace std;

struct node {

int data, left, right;

} tree[500005]; int b[500005], a[500005]; int cnt = 1;

void Inor(int root) {

if (root) {
	Inor(tree[root].left);
	a[cnt++] = tree[root].data;
	Inor(tree[root].right);
}

}

int main() {

int n;
cin >> n;
for (int i = 1; i <= n; i++) {
	int d, l, r;//我是水印
	cin >> d >> l >> r;
	tree[i] = {d, l, r};
	b[i] = d;
}
sort(b + 1, b + 1 + n);
Inor(1);
int ans = 0;
for (int i = 1; i <= n; i++) {
	if (a[i] == b[i])
		ans++;
}
cout << ans;
return 0;

}


评论:

请先登录,才能进行评论