Build a graph
Practice
2.2 (78 votes)
Algorithms
Graphs
Problem
91% Success 16046 Attempts 20 Points 0.5s Time Limit 256MB Memory 1024 KB Max Code
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:
- Its degree is less than or equal to 1.
- 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
\(1\le n\le100\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
234 votes
Tags:
Ad-HocEasyGraphsOpen
Points:20
254 votes
Tags:
ApprovedEasyGraphsOpenTrees
Points:20
34 votes
Tags:
AlgorithmsEasyGraphs
Editorial