#P7393. 「TOCO Round 1」Eternal Star

    ID: 8239 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>树形数据结构递归Special Judge构造

「TOCO Round 1」Eternal Star

Background

"With sincere prayers."

"At the moment when the stars fall."

"Two figures are reflected in the water."

"Shining together."

Problem Description

Kuon wants a tree with as few nodes as possible.

She will assign each node a positive integer label, such that adjacent nodes have different labels and the sum of all node labels is minimized. If there are multiple valid assignments, she will choose any one of them.

Please help construct a tree such that, after Kuon finishes labeling it, the maximum label is guaranteed to be not less than kk.

Input Format

Two integers kk and xx, where kk is as described in the statement, and xx is the scoring parameter.

Output Format

The first line contains an integer nn, the size of the tree you construct.

The next n1n - 1 lines each contain two integers u,vu, v, representing an edge of your tree.

2 5
5
1 2
2 3
3 4
4 5
3 20
16
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16

Hint

The scoring is as follows.

  • If the constructed tree satisfies the requirements and 1nx1 \le n \le x, 1u,vn1 \le u, v \le n, then you will receive the full score for that test case.
  • Otherwise, you will receive 00 points for that test case.
Test Point ID kk xx
11 //
22
33 33 1010
44 88
55 44 4040
66 3434
77 55 //
8168\sim 16 //
1717 1010 5380853808
181918\sim 19 //
2020 1212 519616519616

For 100%100\% of the testdata, 1k121 \le k \le 12, 1x1061 \le x \le 10^6. For each test point, there is guaranteed to be a construction that can achieve full score.

Translated by ChatGPT 5