题目描述
Egor has come up with a hard problem for a training camp! Here it is:
Given an array $a$ of $n$ positive integers sorted in increasing order, find $4$ indices $i \lt j \lt p \lt q$ such that:
$$
a_i\cdot a_q = a_j \cdot a_p
$$
He then wrote the checker to this problem:
```cpp
// returns true if the solution is found,
// returns false if the solution is not found,
// makes the verdict Wrong Answer right away if the found solution is not valid
bool getAnswer(InStream &stream, vector<long long> a) {
string s = stream.readToken("NO|YES"); // PE if the string is not NO or YES
if (s == "NO") return false;
vector<int> b = stream.readInts(4, 1, (int)a.size()); // 4 indices between 1 and n
int i = b[0] - 1, j = b[1] - 1, p = b[2] - 1, q = b[3] - 1; // -1 to make 0-indexed
stream.ensuref(i < j && j < p && p < q, "4 indices should be in increasing order");
stream.ensuref(a[q] / a[p] == a[j] / a[i], "the products are not equal");
return true;
}
```
The multiplication will overflow `long long`, so Egor used division instead. How smart! Although now Egor might have another problem...
输入格式
The first line contains one integer $n$ $(4 \le n \le 500\,000)$ — the size of the array.
The second line contains the array $a_1, a_2, \dots, a_n$ itself $(1 \le a_1 \lt a_2 \lt \dots \lt a_n \le 10^{18})$.
输出格式
On the first line print `YES` if there is a solution and print `NO` otherwise.
If a solution exists, print the $4$ chosen indices in order $i, j, p, q$, separated by spaces. If there is more than one solution, you can print any one.
样例输入 #1
6 2 6 11 21 47 120
样例输出 #1
YES 1 3 4 6
样例输入 #2
5 1 2 6 30 210
样例输出 #2
NO
样例输入 #3
4 7 13 77 143
样例输出 #3
YES 1 2 3 4
样例输入 #4
4 10 29 31 100
样例输出 #4
NO
来源
The 2023 ICPC Training Camp powered by Huawei. Day 1: Um_nik mod 998 244 353 Contest.