Build a graph

2.2

78 votes
Algorithms, Graphs
Problem

You are given an integer n. Determine if there is an unconnected graph with n vertices that contains at least two connected components and contains the number of edges that is equal to the number of vertices. Each vertex must follow one of these conditions:

  1. Its degree is less than or equal to 1.
  2. It's a cut-vertex.

Note

  • The graph must be simple.
  • Loops and multiple edges are not allowed.

Input format

  • First line: n

Output format

Print Yes if it is an unconnected graph. Otherwise, print No.

Constraints

1n100

Sample Input
3
Sample Output
No
Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

There is only one graph with the number of edges equal to the number of vertices (triangle) which is connected.

Editor Image

?