##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a sequence .
Determine whether there exists an undirected multigraph with vertices numbered from to such that:
The graph does not have to be connected. Loops and multiple edges are allowed.
A loop is considered a cycle of length , and it contributes to the degree of its endpoint. Every pair of parallel edges forms a cycle of length . Cycles that use different edges are considered different.
For each test case, output Yes if such a multigraph exists, and No otherwise.
The answer is case-insensitive. For example, YES, yes, and yEs are all accepted.
Place one loop on each of the vertices and add no other edges. Every degree is , and each vertex belongs only to its own loop.
Place one loop on every vertex, then add one edge between vertices and . Their degrees become , the other two degrees remain , and the added edge creates no new cycle.
The degree sum is . In every undirected multigraph, loops included, the degree sum is twice the number of edges and is therefore even. Hence, no such graph exists.
Loops on all vertices and three edges from vertex to vertices , , and give the required degrees.
After reserving degree for one cycle at each vertex, the first vertices would need degree sum in an acyclic graph, which is impossible.