#P2757. [国家集训队] 等差子序列
[国家集训队] 等差子序列
Description
Given a permutation of to , determine whether there exist indices
$$1 \le p_1 < p_2 < p_3 < p_4 < p_5 < \cdots < p_{Len} \le N, \quad Len \ge 3,$$such that form an arithmetic progression.
Input Format
The first line contains an integer , the number of test cases.
Then follow test cases. For each test case, the first line contains an integer , and the second line contains a permutation of to , with numbers separated by single spaces.
Output Format
For each test case, output a single line with Y if there exists an arithmetic subsequence, otherwise output N.
2
3
1 3 2
3
3 2 1
N
Y
Hint
For the first test points, , , time limit s.
For the remaining test points, , , time limit s.
Translated by ChatGPT 5
京公网安备 11011102002149号