Given two sequences $A[1..n]$ and $B[1..m]$ over a totally ordered alphabet, the \emph{Longest Common Bitonic Subsequence} (LCBS) problem asks for a longest common subsequence that is strictly increasing up to a single peak element and strictly decreasing thereafter (allowing either phase to be empty). The only explicitly documented approach evaluates a quadratic dynamic program over the full $n\times m$ grid, which is prohibitive on large inputs. We present two exact algorithms. First, we give a simple $Θ(nm)$-time baseline that computes LCBS by combining a longest common increasing subsequence (LCIS) computation on $(A,B)$ with a second LCIS computation on the reversed inputs, and then maximizing $INC(i,j)+DEC(i,j)-1$ over all common peaks. The method is constructive via parent pointers. Second, we develop an \emph{instance-sensitive} algorithm whose running time depends on the number $\mathcal{M}$ of matching pairs $(i,j)$ with $A[i]=B[j]$. We view matches as vertices of a dominance-ordered poset and compute the increasing and decreasing halves by two 2D dominance DP passes supported by orthogonal range-maximum data structures, followed by a linear peak scan. With a standard 2D range tree (or equivalent), this yields $O(\mathcal{M}\log^{2}\mathcal{M} + \mathcal{M} + (n+m)\log(n+m))$ time and $O(\mathcal{M}\log \mathcal{M})$ space, and it improves over the dense baseline whenever $M\log^2 M\ll nm$.
翻译:给定两个定义在全序字母表上的序列$A[1..n]$和$B[1..m]$,\emph{最长公共双调子序列}(LCBS)问题要求寻找一个最长的公共子序列,该子序列在达到单个峰值元素之前严格递增,之后严格递减(允许任一阶段为空)。目前唯一明确记载的方法是在完整的$n\times m$网格上评估一个二次动态规划,这对于大规模输入而言计算代价过高。我们提出了两种精确算法。首先,我们给出一个简单的$Θ(nm)$时间基线算法,该算法通过结合在$(A,B)$上计算最长公共递增子序列(LCIS)与在反转输入上进行的第二次LCIS计算,然后对所有公共峰值最大化$INC(i,j)+DEC(i,j)-1$来计算LCBS。该方法通过父指针是可构造的。其次,我们开发了一种\emph{实例敏感}算法,其运行时间取决于匹配对$(i,j)$(满足$A[i]=B[j]$)的数量$\mathcal{M}$。我们将匹配视为一个支配序偏序集的顶点,并通过两个由正交范围最大值数据结构支持的二维支配DP过程来计算递增和递减两半,随后进行线性峰值扫描。使用标准的二维范围树(或等价结构),该算法实现了$O(\mathcal{M}\log^{2}\mathcal{M} + \mathcal{M} + (n+m)\log(n+m))$时间和$O(\mathcal{M}\log \mathcal{M})$空间,并且在$M\log^2 M\ll nm$时优于密集基线算法。