题库练习 Unordered Subsequence
← 上一题 下一题 →

A7816 | Unordered Subsequence

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces \[3, 1, 1, 0\] and \[1, 2, 3, 100\] are ordered, but the sequence \[1, 3, 3, 1\] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.

A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.

输入格式

The first line of the input contains one integer $n$ ( $1<=n<=10^{5}$ ). The second line contains $n$ space-separated integers — the given sequence. All numbers in this sequence do not exceed $10^{6}$ by absolute value.

输出格式

If the given sequence does not contain any unordered subsequences, output $0$ . Otherwise, output the length $k$ of the shortest such subsequence. Then output $k$ integers from the range \[1.. $n$ \] — indexes of the elements of this subsequence. If there are several solutions, output any of them.

输入输出样例

输入 #1
5
67 499 600 42 23
输出 #1
3
1 3 5
输入 #2
3
1 2 3
输出 #2
0
输入 #3
3
2 3 1
输出 #3
3
1 2 3
C++ 编辑器
输入
输出