Hamiltonian
Time limit2sMemory limit512 MB
Given K up to 60, build a graph with at most 20 vertices that has exactly K unordered vertex pairs joined by a Hamiltonian path. The output is the graph's edge list.
- Level
Hard8 of 10
- Topics
- Implementation, Graph, Bit manipulation
- Solved
- No attempts yet
Problem
Given a positive integer , construct a graph with at most vertices that has exactly unordered pairs of vertices such that a Hamiltonian path exists between and . It can be shown that a solution always exists under these constraints. A Hamiltonian path is a path between two vertices that visits each vertex exactly once.
Input
The only line of the input contains a single integer ().
Output
On the first line, output two integers and (, ), the number of vertices and the number of edges. In each of the next lines, output one edge (, ). All edges must be distinct.