No.1519 Diversity
タグ : / 解いたユーザー数 125
作問者 :
MZKi
aspi
👑
Nachia
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もしくは右上の雲マークをクリックしてアカウントを作成してください。