I am trying to solve 1818D - Fish Graph with the following idea.
- For each node V whose degree is >= 4, do BFS starting from V to find the shortest cycle that includes V.
- If such a cycle exists, get all the nodes in this cycle, then check if we can add 2 more extra edges from V to other 2 nodes that are not in this cycle.
My submission (with some comments) is : 204063133. However I am getting WA on test case 2: wrong answer edge (4, 8) was used twice (test case 137).
I am sure my logic is incorrect somewhere but couldn't figure it out. Any help is appreciated.