#P5679. [GZOI2017] 等差子序列
[GZOI2017] 等差子序列
Background
GZOI2017 D2T2
Problem Description
Given a positive integer sequence of length , determine whether there exists an arithmetic progression subsequence with length at least three.
Input Format
The first line contains a positive integer , indicating the number of test cases.
Then follow test cases. For each test case, the first line contains a positive integer , indicating the length of the sequence. The second line contains positive integers, in order, representing the numbers in the sequence.
Output Format
For each test case, output a separate line containing YES or NO.
3
4
4 3 2 1
2
1 100
5
1 17 9 18 17
YES
NO
YES
Hint
Constraints
For of the testdata: .
For of the testdata: .
For of the testdata: , , and each number in the sequence is .
Translated by ChatGPT 5