All Tracks Algorithms Graphs Graph Representation Problem

Build a graph
Tag(s):

Algorithms, Graph Representation, Graphs

Problem
Editorial
Analytics

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

\(1\le n\le100\)

SAMPLE INPUT
3
SAMPLE OUTPUT
No
Explanation

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

Time Limit: 0,5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

November Circuits '19

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?