2024春-A-3 Degree of Skewness
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目描述
Given a binary tree, let denotes the number of nodes with only a left child, and the number of nodes with only a right child. The degree of skewness is defined to be . Your job is to calculate for a given binary tree.
输入格式
Each input file contains one test case. For each case, the first lines gives a positive integer () which is the number of nodes in the binary tree. The next two lines contain the post-order and in-order traversal sequences of the tree, respectively. The keys are integers from 1 to . All the numbers in a line are seperated by a space.
输出格式
Print in a line the degree of skewness in the format: = -
样例
7
1 2 7 5 4 3 6
1 2 3 4 7 5 6
2 = 3 - 1
限制
对于所有的测试用例,限制为400 ms, 64 MB