CF353E Antichain
题目描述
有一个 $n$ 个点($n\le10^6$)的 $0…n-1$ 标号的 DAG,有 $n$ 条连接 $i$ 和 $(i+1)\bmod n$ 的有向边(方向是给定的,保证一定会构成一个 DAG),求最长反链。
一个“反链”定义为一个点的集合,使得这个集合内任意两个点互相不能到达。
输入格式
一行一个长为 $n$ 的 01 串,若第 $i$ 位($i\in[0,n-1]$)是 $0$ 则表示 $i$ 向 $(i+1)\bmod n$ 连边,否则 $(i+1)\bmod n$ 向 $i$ 连边。
输出格式
一行一个整数,图的最长反链。
说明/提示
Consider the first test sample. The graph's $ G $ edges are: $ 0→1 $ , $ 1→2 $ , $ 0→2 $ . We can choose the set of vertexes $ [0] $ as the maximum antichain. We cannot choose an antichain of larger size.