After reading the paper Incremental Topological Ordering and Strong Component Maintenance, you came up with the following problem.
You are given a graph with n vertices. There are no edges initially. There are m operations. Each operation is first to add a given directed edge to the graph, and then to output the number of pairs (u,v) (1≤u<v≤n) such that u is reachable from v and v is reachable from u.
Can you implement the algorithm described in the paper in an ICPC contest?