問題一覧 > 通常問題

No.1519 Diversity

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 125
作問者 : NatsubiSogan / テスター : MZKi aspi 👑 Nachia
お気に入りにしたユーザー ProblemId : 5891 / 自分の提出
問題文最終更新日: 2021-05-12 20:04:01
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 297 (順位表) の他の問題:

Problem Statement

Construct $1$ simple undirected graph with $N$ vertices numbered from $1$ to $N$ such that the number of distinct values among the elements of its degree sequence is maximized.

Notes

  • An undirected graph $G$ is simple if $G$ has no self-loops or multiple edges.
  • The degree sequence of an undirected graph $G$ is the sequence of the degrees of the vertices of $G$ arranged in descending order.

Input

$N$

  • $N$ is an integer satisfying $2 \leq N \leq 500$

Output

Output the constructed graph in the following format. All output values must be integers.

$M$
$u_1\ v_1$
$u_2\ v_2$
$\vdots$
$u_M\ v_M$
$M$ on line $1$ of the output represents the number of edges in the graph. It must satisfy $0 \leq M \leq \frac{N(N-1)}{2}$.

Line $i+1\ (1 \leq i \leq M)$ of the output indicates that the $i$-th edge connects vertices $u_i$ and $v_i$ bidirectionally. It must satisfy $1 \leq u_i,v_i \leq N$.

The edges may be output in any order.

Print a newline at the end.

Sample

Sample 1
Input
3
Output
2
1 3
2 3

This is one example of a valid solution. In this case, the degree sequence is $(2,1,1)$, and the number of distinct values among the elements of this sequence is $2$. This is the maximum number of distinct values for $N=3$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。