Editorial for DMOPC '23 Contest 1 P6 - Sky Clearing Up
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Hint 1
Build a graph over all companies, where two companies are adjacent if they interfere with one another.
Hint 2
What subset of companies can be shut down?
Hint 3
What subset of companies can be left open?
Key Ideas
Let be the graph over the companies, where
is the set of companies, and for companies
, we have
if and only if companies
and
interfere. The problem reduces to finding a non-empty set
where
is a clique), and
does not contain
(or alternatively,
is a disjoint set of cliques). Intrepid users may immediately observe that graphs that satisfy the previous property resemble split graphs. Indeed, the problem reduces to recognizing if
is Unipolar.
However, currently the fastest algorithm for recognizing a Unipolar graph runs in , so naively implementing an algorithm from the internet would blow past the time limit. Moreover, reconstructing
in any capacity could blow past the time limit, as both
, so it'd be impossible to store information on edges.
Lets make some more observations: clearly, if contains an induced
(namely, two fully disjoint copies of
), then
is not Unipolar. This is because no clique can cover both copies of
, so no matter what clique is removed, a
will always remain. At a glance, this is not helpful, as checking if a graph is
-free is difficult, does not yield a clique for us to remove, and may not guarantee that
is Unipolar.
We make an additional observation key to solving the problem, namely that companies and
interfere if and only if the smallest subtree containing every station owned by company
intersects with the smallest subtree containing every station owned by company
. Thus,
is the intersection graph of some subtrees. Thus, it turns out that
is the only obstruction to Unipolarity. We provide a proof: suppose
does not contain
. For each edge
, let
be the subset of vertices whose subtrees contain
. If
does not contain
, then
is Unipolar. Otherwise, let
be the two trees obtained from deleting
. Since
does not contain
, then
only contains one
. Moreover, the vertices in said
must correspond to subtrees in the same component (
or
). Then we direct
towards the component containing vertices that induce a
in
. Since
, there is a vertex
of
with no out-going edge. Then removing the clique corresponding to all subtrees that share
must yield a
-free graph.
Our proof also yields an algorithm for checking if a graph is Unipolar. Root at its centroid, and let
be components of
after removing its centroid. We check if removing the clique of
consisting of all subtrees containing
's centroid yields a
-free graph. If it does, then we conclude. Otherwise, if more than one of
contains subtrees that are a part of a
in
, then we output
. Otherwise, WLOG suppose that
is the only component containing subtrees that induce a
in
. Then repeat with
's centroid. As the height of the centroid tree is
, our algorithm runs in
time, where
is the time it takes to check if
contains a
after removing a clique. Of course there are some additional subtleties that need to be considered.
There are several algorithms which can yield an optimal value for , which will be discussed in their respective subtasks
Subtask 1
Solution
In this case, is a path graph, and
is an interval graph, so removing a vertex from
yields at most two connected components. We can check there are three intervals that form a
in
by carefully iterating over the intervals in increasing order of their left endpoint, while maintaining the interval intersecting with the current interval that extends the furthest to the right. Implementation details are left as an exercise.
Time Complexity:
Subtask 2
Solution
In this case, has at most one vertex of degree
, so it's several paths concatenated at an endpoint. There is no intended algorithm, but a possible solution could be running the algorithm described in Subtask 1 once for each of the graph's branches, then carefully processing each branch to check if there is a
consisting of subtrees that straddle the center vertex.
Time Complexity: or
Subtask 3
Hint
What does it mean for a graph to be -free?
Full Solution
Note that a graph is -free if it is a disjoint set of cliques. Consider the following algorithm: first, subdivide
by adding a vertex on each edge. Next, for a vertex
, let
denote the number of subtrees that contain
. We say that
is a local maxima if every path
leading away from
, there is a prefix
s.t.
, and either
is a leaf or
. We observe that
is
-free if and only if, when walking outwards from any local maxima,
is non-increasing until reaching a vertex
where
.
There are multiple ways to construct
. One implementation involves incrementing subtrees offline by "walking inwards" from every leaf of
, while "pushing" vertices owned by companies inwards. Using small-to-large merging yields a runtime of
. Another Implementation involves constructing a virtual tree over the set of stations each company owns, and using Heavy-Light Decomposition to increment subtrees. While this normally takes
, we observe that we don't need to perform incrementations online, so we can use a prefix-sum array to reduce the complexity to
. Some additional constant optimizations may be required in both cases.
Time Complexity: or
Additional Remarks
Additional Remarks
Thanks to a structural theorem that chordal graphs are precisely the intersection graphs of subtrees, we note that -free Chordal graphs are precisely the set of Unipolar Chordal graphs. A proof does exist in literature (by A.V. Gagarin), but the paper is not in English, and to the knowledge of the problem author, not available online (so it was not consulted when creating this problem).
Special thanks to Professor Spirkl at the University of Waterloo, who encountered this proof during her research.
To not-so-subtle reference didn't escape you, and that we'll be alright moving forwards.
, I hope that theAddendum: It turns out that
didn't even write the contest. What a weeb...
Comments