I'm having trouble solving this problem.I, at first, thought to read the edges one by one and build an MST (using DSU) while allowing the first edge that is (u -> u).Then, when encountering an edge that would result in a cycle, I would redirect it to a node not in it's set(meaning their sets are disjoint).
But then I realised that looking for a node this way would take O(N)..
Looking at the editorial confused the hell out of me.The author took the edges as directed and was talking about reading all the edges then detecting cycles one by one(wouldn't that be O(N²) operations?)..
Any hints would be appreciated !