无序子序列AI (CI翻译)
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.
序列被称为有序,当且仅当它是非递减的或非递增的。例如,序列 [3, 1, 1, 0] 和 [1, 2, 3, 100] 是有序的,但序列 [1, 3, 3, 1] 不是有序的。给定一个数字序列,请找出其中最短的无序子序列。AI (CI翻译)
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.
子序列是指从给定序列中删除零个或多个元素,且不改变剩余元素相对顺序后得到的序列。AI (CI翻译)
Input
输入格式
AI (CI翻译)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.
输入的第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 10^{5}$)。第二行包含 $*n*$ 个以空格分隔的整数,即给定的序列。该序列中的所有数字的绝对值均不超过 $10^{6}$。AI (CI翻译)
Output
输出格式
AI (CI翻译)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.
如果给定序列不存在任何无序子序列,输出 $0$。否则,输出最短无序子序列的长度 $*k*$。然后输出 $*k*$ 个范围在 [1..$*n*$] 内的整数,表示该子序列中各元素的下标。如果存在多个解,输出任意一个即可。AI (CI翻译)
样例
5
67 499 600 42 23
3
1 3 5
3
1 2 3
0
3
2 3 1
3
1 2 3
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。