Given a directed graph G that consists of (multiple of) a node connected to a segment of nodes, how would you find its SCC?
But here I propose a very simple algorithm that can solve this problem in the same time complexity ($$$O((M + N) \log N))$$$ (with M being the number of segments and N being the number of nodes).
Why this works: dfs or dfs_T will always call on an existing node, so it'll be called n times. The time complexity is obvious from the set complexity.
Application: https://atcoder.jp/contests/arc069/submissions/78513905.
But what about the graph consisting of segments connected to segments? It probably can be solved in $$$O((M+N)\log^2(N))$$$ with the segment tree method, but doesn't apply here. I guess...
Also the problem above has a trivial transpose ($$$|M^T|=|M|$$$) of the graph. This probably makes it easier...








why $$$O((M+N) log^2(N))$$$?
Perhaps creating "Virtual points" could solve this problem in $$$O((M+N) log N)$$$.(use segment tree)
The time complexity comes from the fact that you probably need to connect all pairs of segment tree vertices together. I haven't thought much of this problem, since it's a generalization of the above problem and can solve the transpose case by itself.
The points on the segment tree are connected to a new point, and the new point is connected to points on another segment tree.
Given a directed graph G that consists of (multiple of) a node connected to a segment of nodes, how would you find its SCC?
In fact,It can $$$O((N+M)\alpha(N))$$$.Use Kosaraju and DSU.
isn't that exactly the same as my algorithm but substituting set for DSU?... I guess my algorithm is trivial...
also, how would you implement the DSU?
During the two DFS operations of Kosaraju, a union-find data structure was used to maintain the first unvisited point within each interval.
If a point is visited, it is merged with the next one, and the maximum point within each set is recorded.
It took me a long time to study the code of a certain player before I understood it.
A problem that seemingly has a nontrivial transpose: https://oj.vnoi.info/problem/icpc26_mn_i.
(I tried to construct the transpose graph but failed).
Add edges from vertex $$$i$$$ to the last vertex that is constrained to set on top of it for every $$$x$$$ in $$$[l; r]$$$.