#P5679. [GZOI2017] 等差子序列

    ID: 4649 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2017各省省选O2优化枚举,暴力贵州

[GZOI2017] 等差子序列

Description

Given a positive integer sequence of length NN, determine whether there exists an arithmetic progression subsequence with length at least three.

Input Format

The first line contains a positive integer TT, indicating the number of test cases.

Then follow TT test cases. For each test case, the first line contains a positive integer NN, indicating the length of the sequence. The second line contains NN 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 20%20\% of the testdata: N100N \le 100.

For 40%40\% of the testdata: N103N \le 10^3.

For 100%100\% of the testdata: 1T101 \le T \le 10, 1N2×1041 \le N \le 2 \times 10^4, and each number in the sequence is 2×104\le 2 \times 10^4.

Translated by ChatGPT 5