#P6342. [CCO 2017] Vera 与道路建设

[CCO 2017] Vera 与道路建设

Description

Vera likes hiking, so she wants to build her own road network. The road network contains vv locations, numbered 1,2,,v1,2,\ldots,v. The network consists of ee undirected roads connecting aia_i and bib_i. The graph is guaranteed to be connected, and multiple edges are allowed.

Vera calls two locations a,ba,b with a<ba < b a perfect pair if there exists a walk that starts from aa, goes to bb, and then returns to aa, such that each road is traversed at most once.

Vera thinks her road network is beautiful if it contains exactly kk perfect pairs.

Given kk, help Vera find a beautiful road network.

Input Format

The input contains one line with an integer kk.

Output Format

Output a beautiful road network in the following format:

  • The first line contains the number of vertices vv and the number of edges ee.
  • The next ee lines each contain two integers aia_i and bib_i, indicating that there is an edge between aia_i and bib_i (1ie1 \le i \le e).

The order of the edges does not matter. If there are multiple beautiful road networks, you may output any one of them.

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

Hint

Sample Explanation

For sample 11, the perfect pairs are 1,2 and 3,4.

For sample 22, every pair of vertices is a perfect pair.

Constraints and Notes

This problem uses bundled testdata, with a total of 33 subtasks.

  • Subtask 1 (12 points): 0k1030 \le k \le 10^3.
  • Subtask 2 (24 points): 0k1050 \le k \le 10^5.
  • Subtask 3 (64 points): 0k1070 \le k \le 10^7.

For all testdata, it is guaranteed that 0k1070 \le k \le 10^7 and 1v,e5×1031 \le v,e \le 5 \times 10^3.

Source: CCO 2017 Day 1 “Vera and Trail Building”.

Note: This translation is from LOJ.

Translated by ChatGPT 5