其他分享
首页 > 其他分享> > [ARC111D] Orientation

[ARC111D] Orientation

作者:互联网

https://atcoder.jp/contests/arc111/tasks/arc111_d

Statement

Given is a simple undirected graph with \(N\) vertices and \(M\) edges. The vertices are numbered \(1, \cdots, N\), and the \(i\)-th edge connects Vertices \(a_i\) and \(b_i\). Also given is a sequence of positive integers: \(c_1, c_2, \cdots, c_N\).

Convert this graph into a directed graph that satisfies the condition below, that is, for each \(i\), delete the undirected edge \((a_i, b_i)\) and add one of the two direted edges \(a_i \to b_i\) and \(b_i \to a_i\).

For every \(i = 1, 2, \cdots, N\), there are exactly \(c_i\) vertices reachable from Vertex \(i\) (by traversing some number of directed edges), including Vertex \(i\) itself.
In this problem, it is guaranteed that the given input always has a solution.

Solution

显然,若\(c_i\)不同,则把边的方向从大到小定向即可;\(c_i\)相同的相邻点必定属于同一强联通分量。现在的问题在于如何构造强联通分量。

Proposition 2.3. If vertices \(x\) and \(y\) are adjacent in \(G\), then one
of them is a descendant of the other in any depth-first search tree
\(T\) of \(G\).

Proposition 2.4. Let \(\{x, y\}\) be an edge of \(T\) which is not an
isthmus in \(G\); say \(x\) is the parent of \(y\). Then there is an edge in \(G\)
but not in \(T\) joining some descendant \(a\) of \(y\) and some ancestor \(b\)
of \(x\).

Theorem 2.5. Let \(G\) be a finite connected graph without isthmuses.
Then \(G\) admits a strong orientation, i.e. an orientation
that is a strongly connected digraph.

——《A course in combinatorics》

Proposition 2.3 由DFS树的性质,知不可能存在横叉边,仅有返祖边与树边,即证。

Proposition 2.4:由\(\{x,y\}\)不是桥,知\(y\)的子树中有连到\(y\)子树外的返祖边,由Proposition 2.3,这条返祖边连向\(x\)或其祖先。

如此构造:在\(G\)的DFS树\(T\)中,将树边从祖先定向到儿子;将返祖边从儿子定向到祖先。

显然,根可以到达所有其它节点,故只需证明任何其它节点都能到达根。由Preposition 2.4可知每个节点都可以到他的祖先,如此反复即证。

标签:Orientation,返祖,graph,some,vertices,edge,Proposition,ARC111D
来源: https://www.cnblogs.com/topsecret/p/arc111d.html