QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#18297. Clique Partition

Estadísticas

We have a complete undirected graph of size $n$: for all pairs of vertices $(u, v)$ such that $1 \le u < v \le n$, there exists an edge between $u$ and $v$. Find a way to represent the set of edges in this graph as a union of several $n$-vertex trees.

Let $k$ be the number of trees, and $T_1, \ldots, T_k$ be the trees. Then:

  • Each $T_i$ should be a tree with $n$ vertices numbered from $1$ to $n$ and $n - 1$ edges.
  • The union of all edges of all trees should form a complete graph.
  • The number of trees $k$ should be the minimum possible.

Input

The first line contains an integer $n$, the size of the graph ($2 \le n \le 1000$).

Output

On the first line, print $k$, the number of trees. The number $k$ should be the minimum possible. After that, print the $k$ trees, one after another, without empty lines.

For each tree, print $n - 1$ lines denoting its edges. For each edge, print a line with two integers $u$ and $v$: the vertices connected by this edge.

If there are several optimal answers, print any one of them.

Examples

Input 1

2

Output 1

1
1 2

Input 2

3

Output 2

2
1 2
1 3
1 3
2 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.