You are given a directed graph of N nodes. Initially there are M directed edges which are given as input (these are unique and self edges are allowed). You can add a new edge (c, a) if the edges (a,b) and (b,c) exist in the graph. Find the total no of edges in the final graph (when you cannot add any more edges)
NOTE: (a,b) & (b,c) => (c,a) and NOT (a,c)
Constraint: N = 100,000, M = 100,000, TimeLimit = 2s
I am reposting this blog as I accidentally deleted the old blog with the same problem (I thought I was discarding the edit and deleted it)
problem
solution
thanks for finding this. Did you find this problem from the memory of seeing this in a previous contest ? ( I am curious how did you find the exact contest even if you remembered that you saw/solved this problem in an earlier contest )
agc F 💀