Problem Link :
Author: Amrutansu Garanaik , Abhishek Patnaik
Tester: Keshow Sablaka, Amit Das
Editorialist: Amrutansu Garanaik , Amit Kumar Sahu
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?
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.