atcoder#ARC161D. [ARC161D] Everywhere is Sparser than Whole (Construction)
[ARC161D] Everywhere is Sparser than Whole (Construction)
Score : points
Problem Statement
We define the density of a non-empty simple undirected graph as $\displaystyle\frac{(\text{number\ of\ edges})}{(\text{number\ of\ vertices})}$.
You are given positive integers and . Determine whether there is a simple undirected graph with vertices and edges that satisfies the following condition. If it exists, find one such graph.
Condition: Let be the vertex set of . For any non-empty proper subset of , the density of the induced subgraph of by is strictly less than .
What is an induced subgraph?
For a vertex subset of graph , the induced subgraph of by is the graph with vertex set and edge set containing all edges of that connect two vertices in . In the above condition, note that we only consider vertex subsets that are neither empty nor the entire set.
Constraints
Input
The input is given from Standard Input in the following format:
Output
If there is a simple undirected graph that satisfies the condition, print Yes
; otherwise, print No
.
Furthermore, in the case of Yes
, print a graph that satisfies the condition in the following format in the next lines.
If multiple graphs satisfy the condition, any of them will be considered correct.
- $\{A_i, B_i\} \neq \{A_j, B_j\} \ \ (1 \leq i < j \leq DN)$
- The vertices of the graph are numbered from to .
- The -th line of the output represents that the -th edge connects vertex and vertex .
- The order of the edges (which edge is printed first) and the order of the vertices (which endpoint of each edge is printed first) may be arbitrary.
3 1
Yes
1 2
1 3
2 3
The printed graph has vertex set and edge set , and is simple. The vertex set has non-empty proper subsets: .
- For , the edge sets of the induced subgraphs by are empty, and the densities are .
- For , the edge sets of the induced subgraphs by are , respectively, and the densities are all .
In all cases, the density of the induced subgraph is strictly less than , so this graph satisfies the condition.
4 2
No
A simple undirected graph with vertices and edges does not exist.