Codeforces 1017C The Phone Number

题目

对于 $1$ 到 $n$ 的一个排列,用 LIS 表示其最长上升子序列的长度,用 LDS 表示其最长下降子序列的长度。输出一个使得 LIS + LDS 最小的排列。

分析

这道题是 CF Round 502 的 C 题。比赛时我毫无思路,过了 D 题之后,面对 C 束手无策,非常难受。下面来仔细说一说「如何思考这个问题」。

观察样例可以看出一种「使得 LIS + LDS 比较小」的排列模式(pattern)。

将 $1$ 到 $n$ 分成 $k$ 组,每一组都单调递增,第 $i$ 组的最小值大于第 $i+1$ 组的最大值;比如 $n= 9$,7,8,9|4,5,6|1,2,3 就是一个满足上述条件的排列,8,9|5,6,7|1,2,3,4 也是。设第 $i$ 组有 $a_i$ 个数,则 $\mathsf{LIS} = \max_{i =1}^{k} a_k$,$\mathsf{LDS} = k$ 。

当划分的组数 $k$ 确定时,显然 LIS 的最小值为 $\lceil n/k \rceil$ 。于是问题化为 $\arg\limits_k\min k + \lceil n/k \rceil $ 。暴力枚举 $k$ 即可。前已说明,这并不一定是最优解,只是一个上界。

自然的,现在我们要考虑的问题是

是否存在一个排列满足 $\mathsf{LIS} < \lceil \frac{n}{\mathsf{LDS}} \rceil $?

这个问题也可以表述为

是否存在一个排列满足 $\mathsf{LDS} < \lceil \frac{n}{\mathsf{LIS}} \rceil $?

因为将排列翻转(reverse)以后, LIS 与 LDS 就互换了。

如果我们能证明这样的排列不存在,那么就证明了上面求出的上界亦是下界。

我们将证明这样的排列确实不存在。

前置知识

  1. 偏序集(partially ordered set,poset)

  2. 链 (chain),反链(antichain)

Dilworth 定理

For any finite partially ordered set, there exists an antichain $A$, and a partition of the order into a family $P$ of chains, such that the number of chains in the partition equals the cardinality of $A$.

Notes:定理中所谓「a partition of the order」即「a partition of the poset」。

若某条反链 $A$ 与某个链划分 $P$ 大小(cardinality)相等,必然有

  1. $A$ 是偏序集中的一条最长反链。
  2. $P$ 是偏序集的最小链划分。

证明:对于任意一个链划分 $P$,设 $C$ 是其中的一条链,则 $A$ 中至多有一个元素来自于链 $C$ 。也就是说,对于任意反链 $A$ 和任意链划分 $P$,有 $|A| \le |P|$ 。

因此,Dilworth 定理也可表述为

任意有限偏序集的最长反链的长度,等于其最小链划分中链的个数。

Note:所谓「链/反链的长度」是指其中的元素个数。

Dilworth 定理与我们要证明的东西有什么联系呢?

我们可以从一个排列构造出一个偏序集:
设 $a_1, a_2, \dots, a_n$ 是一个 $1$ 到 $n$ 的排列,令 $S$ 是 $n$ 个二元组 $(a_i, i)$ 构成的集合,定义 $S$ 上的偏序 $<$ 为 $ (a_i, i) < (a_j , j)$ 当且仅当 $a_i < a_j$ 且 $ i < j$ 。于是 $S$ 中的最长链的长度即 LIS,最长反链的长度即 LDS。对于偏序集 $S$ 的任意链划分 $P$,我们有,「最长链的长度」大于等于 $\lceil \frac{n}{|P|} \rceil$,又因为存在链划分 $P$ 使得 $|P|$ = 「最长反链的长度」,于是我们有 $\mathsf{LIS } \ge \lceil \frac{n}{\mathsf{LDS}} \rceil$ 。

Reference

https://codeforces.com/blog/entry/61081?#comment-450158

https://codeforces.com/blog/entry/61081?#comment-450152

猜你喜欢

转载自www.cnblogs.com/Patt/p/9447468.html