Anti Binary Search Tree
题号:NC217612
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

    For a binary tree, let  be the set of all its vertices and  be the key of a vertex . We say this binary tree is an anti binary search tree if for all , at least one of the following statement is true:

  • Vertex  is a leaf;
  • Vertex  has a left child  and ;
  • Vertex  has a right child  and .

    Given  integers , please construct an anti binary search tree such that the multi-set of the keys of all vertices in the tree equals to the multi-set of these  integers, and that the height of the tree does not exceed , where  indicates the smallest integer that is not smaller than .

    Recall that the height of the tree is the maximum number of edges between the root of the tree and any vertex on the tree. That is to say, a tree with only one vertex has a height of 0, and a tree with two vertices has a height of 1.

输入描述:

    There are multiple test cases. The first line of the input contains an integer  indicating the number of test cases. For each test case:

    The first line contains an integer  () indicating the number of given integers.

    The second line contains  integers  () indicating the given integers.

    It's guaranteed that the sum of  of all test cases will not exceed .

输出描述:

    For each test case, if such anti binary search tree exists, first output "Yes" (without quotes) in one line, then output  lines indicating the constructed binary tree. For these  lines, the -th line contains 3 integers  and  separated by a space, indicating the key of the -th vertex, the index of its left child and the index of its right child.  indicates that this vertex does not have a left child, while  indicates that this vertex does not have a right child. Vertex number 1 must be the root. If there are multiple valid answers, you can output any of them.

    If no such anti binary search tree exists, just output "No" (without quotes) in one line.

示例1

输入

复制
3
4
1 2 3 2
3
1 1 1
5
1 1 1 1 2

输出

复制
Yes
3 2 3
2 0 0
1 4 0
2 0 0
No
Yes
1 2 5
2 3 4
1 0 0
1 0 0
1 0 0