#P16310. [ICPC 2023 Jinan R] 开灯 2

    ID: 18246 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>2023Special JudgeICPC济南

[ICPC 2023 Jinan R] 开灯 2

Problem Description

:::epigraph Lux et Veritas

(Light and Truth) :::

The much-anticipated Universal Cup Finals are coming soon. Xiaoqingyu is busy preparing the competition venue. To make the venue colorful and dazzling, Xiaoqingyu plans to hang some light bulbs.

Xiaoqingyu has mm wires and wants to use them to connect nn bulbs. Each wire must connect two different bulbs, and all bulbs must form a connected component. For safety, there can be at most one wire directly connecting any pair of bulbs, and each bulb can be connected to at most dd wires.

After connecting the bulbs, Xiaoqingyu wants to turn on some of them. Since lit bulbs generate heat, it may be dangerous to have two adjacent bulbs lit at the same time. Therefore, if two bulbs are directly connected by a wire, they cannot be lit simultaneously. On the other hand, he also does not want too few lights, so he does not want to see a bulb that is off while all bulbs directly connected to it are also off.

Xiaoqingyu is very curious: under these constraints, how many different ways are there to light these bulbs? In addition, he wants to find a way to connect all bulbs such that the number of lighting plans is maximized.

Given integers mm and dd, your goal is to help Xiaoqingyu determine the best way to use all mm wires to connect nn bulbs so that the number of ways to light the bulbs is maximized. Note that you need to choose the value of nn by yourself.

Input Format

There are multiple test cases. The first line contains an integer TT (1≤T≤2001 \leq T \leq 200), denoting the number of test cases. For each test case:

The first line contains two integers mm and dd (2≤m≤202 \le m \le 20, 2≤d≤m2 \le d \le m).

Output Format

For each test case:

The first line outputs an integer ww (1≤w≤2m+11 \leq w \leq 2^{m+1}), meaning the maximum possible number of ways to turn on the bulbs.

The second line outputs an integer nn (1≤n≤m+11 \leq n \leq m+1), meaning the number of bulbs Xiaoqingyu needs to use.

Then output mm lines. In the ii-th line, output two integers uiu_i and viv_i separated by a single space (1≤ui,vi≤n1 \le u_i, v_i \le n, ui≠viu_i \neq v_i), representing a wire connecting the uiu_i-th bulb and the viv_i-th bulb.

3
2 2
5 4
6 2
2
3
1 2
2 3
5
5
1 2
1 3
2 3
1 4
4 5
7
7
1 2
2 3
3 4
4 5
5 6
6 7

Hint

We use colored circles to represent bulbs that are turned on.

For the first sample testdata, the 22 lighting plans are shown in the figure below.

:::align{center} :::

For the second sample testdata, the 55 lighting plans are shown in the figure below.

:::align{center} :::

Translated by ChatGPT 5