시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 32 | 18 | 17 | 68.000% |
Given an integer number K, generate a tree with minimum number of nodes such that there are exactly K pairs of nodes (X, Y), where X is an ancestor of Y.
The input (from the console) will contain a single integer number, K – the number of pairs with the specified property.
The output (to the console) will contain N+1 lines, representing the generated tree, the nodes being indexed from 0.
The first line will contain the number N – the number of nodes in the tree.
The following N lines will contain each 2 numbers X and T, separated by a space, with the following meaning: node T is the direct ancestor of node X. If node X doesn’t have a direct ancestor, T will have value -1.
For every test, you will get:
Ncommittee is the minimum number of nodes that a tree with the specified property can be generated with.
번호 | 배점 | 제한 |
---|---|---|
1 | 20 | 0 ≤ K ≤ 50 |
2 | 30 | 0 ≤ K ≤ 500 |
3 | 50 | 0 ≤ K ≤ 109 |
2
3 0 -1 1 0 2 0
There are 2 pairs (X, Y), such that X is the ancestor of Y:
4
4 0 -1 1 0 2 0 3 2
There are 4 pairs (X, Y), such that X is the ancestor of Y: