## Editorial for DMOPC '18 Contest 6 P3 - Wish Upon a Star

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**Authors:

For of points, we can add each edge, and see if it forms a cycle (namely, it connects two already connected nodes). We count the number of such edges, and output `YES`

if there is at most 1 such edge, and `NO`

otherwise.

**Time Complexity:**

Let denote the number of connected components. This can be computed in using DFS.

For of points, we observe that the answer is always yes if or . The first case gives us a forest, and the second case forms a forest with a single extra edge.

**Time Complexity**:

## Comments