QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100

#11910. 之字形

統計

我们称一个数字序列 $x(1), x(2), \dots, x(k)$ 为 zigzag 序列,如果其中任意三个连续元素都不构成非递增或非递减序列。更准确地说,对于所有 $i = 1, 2, \dots, k-2$,必须满足 $x(i+1) < x(i)$ 且 $x(i+1) < x(i+2)$,或者 $x(i+1) > x(i)$ 且 $x(i+1) > x(i+2)$。

给定两个数字序列 $a(1), a(2), \dots, a(n)$ 和 $b(1), b(2), \dots, b(m)$。本题要求计算它们的最长公共 zigzag 子序列的长度。换句话说,你需要从两个序列中删除若干元素,使得剩余部分相等,且剩余的序列是一个 zigzag 序列。

样例

输入格式 1

5 1 2 5 4 3
5 4 1 2 5 3

输出格式 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.