CF1332G No Monotone Triples
Description
Given a sequence of integers $ a $ of length $ n $ , a tuple $ (i,j,k) $ is called monotone triples if
- $ 1 \le i
Input Format
The first line contains two integers $ n $ , $ q $ ( $ 3 \le n \le 2 \cdot 10^5 $ , $ 1 \le q \le 2 \cdot 10^5 $ ) — the length of sequence $ a $ and the number of queries.
The second line contains $ n $ integers $ a_1,a_2,\ldots, a_n $ ( $ 1 \le a_i \le 10^{9} $ ), representing the sequence $ a $ .
Then each of the following $ q $ lines contains two integers $ L $ , $ R $ ( $ 1 \le L,R \le n $ , $ R-L\ge 2 $ ).
Output Format
For each query, output $ 0 $ if there is no subsequence $ b $ satisfying the constraints mentioned in the legend. You can print the empty line after but that's not mandatory.
Otherwise, output one integer $ k $ ( $ k > 2 $ ) denoting the length of sequence $ b $ , then output $ k $ integers $ i_1, i_2, \ldots, i_k $ ( $ L \le i_1 < i_2
Explanation/Hint
For the first query, the given sequence itself is monotone triples free.
For the second query, it can be shown that there is no subsequence $ b $ with length greater than $ 2 $ such that $ b $ is monotone triples free.