BIGO04-Editorial

Problem Link :

Practice
Contest

Author: Amrutansu Garanaik , Abhishek Patnaik

Tester: Keshow Sablaka, Amit Das

Editorialist: Amrutansu Garanaik , Amit Kumar Sahu

Difficulty :

Easy

Pre-requisite Graph theory

Problem :

Given a set of cities and bi-directional roads connecting them. Is it possible to travel through
all roads exactly once and come back to the starting point?

Explanation

The problem asks whether there exists an Eulerian circuit in a graph or not. If so, it is
possible to traverse all the edges exactly once and come back to starting node.
A graph has a Eulerarian circuit if each vertices have even degrees. So, we just have to store
the degrees of each node (here the cities) and count whether there is a node with odd degree. If so,
print “NO” , otherwise “YES”.

Check setter solution for implementation.

N.B. The test cases were a bit weak, so some wrong answers also passed the test cases. We are sorry
for that. But if your answer gave WA, then it means your answer is definitely wrong. For AC
however, it might or might not be wrong.

@dragonemperor For euler circuit to exist . The graph should be connected right .? But I got AC by just checking the even degree of every node

Yes, you are right. For our test cases, we created some graphs using pen and paper and used them to create the test files. Unfortunately all the graphs were connected. Also some wrong answers were accepted because of that.