• [1186] Get the Width

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • It's an easy problem. I will give you a binary tree. You just need to tell me the width of the binary tree.
    The width of a binary tree means the maximum number of nodes in a same level.


    For example, the width of binary tree above is 3.

  • 输入
  • The first line is an integer T, means the number of cases.
    Then follow T cases.
    For each case, the first line is an integer N, means the number of nodes. (1 <= N <= 10)
    Then follow N lines. Each line contains 3 integers P A B; indicate the number of this node and its two children node. If the node doesn’t have left child or right child, then replace it by -1.
    You can assume the root is 1.
  • 输出
  • For each case, output the width.
  • 样例输入
  • 1
    6
    4 -1 -1
    2 4 5
    5 -1 -1
    1 2 3
    6 -1 -1
    3 -1 6
    
  • 样例输出
  • 3
    
  • 提示
  • 来源
  • Ne123123
  • 操作

显示春菜