当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6357:Hills And Valleys

Special Judge 特殊评判
题目描述
Tauren has an integer sequence $A$ of length $n$ (1-based). He wants you to invert an interval $[l, r]$ $(1 \leq l \leq r \leq n)$ of $A$ (i.e. replace $A_l, A_{l + 1}, \cdots, A_r$ with $A_r, A_{r - 1}, \cdots, A_l$) to maximize the length of the longest non-decreasing subsequence of $A$. Find that maximal length and any inverting way to accomplish that mission.
A non-decreasing subsequence of $A$ with length $m$ could be represented as $A_{x_1}, A_{x_2}, \cdots, A_{x_m}$ with $1 \leq x_1 < x_2 < \cdots < x_m \leq n$ and $A_{x_1} \leq A_{x_2} \leq \cdots \leq A_{x_m}$.
输入解释
The first line contains one integer $T$, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains one integer $n$.
The second line contains $n$ integers $A_1, A_2, \cdots, A_n$ without any space.
$1 \leq T \leq 100$, $1 \leq n \leq 10^5$, $0 \leq A_i \leq 9$ $(i = 1, 2, \cdots, n)$.
It is guaranteed that the sum of $n$ in all test cases does not exceed $2 \cdot 10^5$.
输出解释
For each test case, print three space-separated integers $m, l$ and $r$ in one line, where $m$ indicates the maximal length and $[l, r]$ indicates the relevant interval to invert.
输入样例
2
9
864852302
9
203258468
输出样例
5 1 8
6 1 2

提示
In the first example, 864852302 after inverting [1, 8] is 032584682, one of the longest non-decreasing subsequences of which is 03588.
In the second example, 203258468 after inverting [1, 2] is 023258468, one of the longest non-decreasing subsequences of which is 023588.
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6357

最后修改于 2020-10-25T23:30:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)