2023.11.10 闲话

Manhattan Subarrays II

对于一列点 \(\{x_k\}\),若

\[\operatorname{dist}(x_1,x_k)=\sum_{i=1}^{k-1}\operatorname{dist}(x_i,x_{i+1}) \]

(其中 \(\operatorname{dist}(x,y)\) 是 Manhattan 距离)

则称 \(\{x\}\) 是好的 .

给一列点 \(\{a_n\}\) 和正整数 \(k\),问有多少个子段不存在长为 \(k\) 的好子序列 .

\(1\le n\le 10^5\)\(1\le k\le 10\) .

显然一列点是好的当且仅当它们每维都是单调的 . 观察可以发现不存在长度不小于 \(k^2\) 的好序列,因为有某定理:

Theorem (Erdos–Szekeres)

\((S,\prec)\) 为偏序集,\(m,n\in\mathbb N^+\)\(|S|=mn+1\),那么 \(S\) 存在长为 \(m+1\) 的链或长为 \(n+1\) 的反链 .

然后暴力就完了,时间复杂度 \(\Theta(nk^2)\) .

posted @ 2023-11-10 16:54  Jijidawang  阅读(28)  评论(1编辑  收藏  举报
😅​