luogu#P7769. 「CGOI-1」大师选徒
「CGOI-1」大师选徒
Background
Recently, many people have come to the "Ugly Country" to learn bc. The bc masters ac and mc want to choose some students from all students to teach bc skills.
2021.8.29: Added a set of hack.
Problem Description
There are students standing in a line, and each student has an ugliness value . Now ac and mc will each choose a continuous segment of students to teach bc.
Because ac and mc have a very good relationship, the two chosen segments must have the same number of students, and the sum of the ugliness values of students in corresponding positions must all be .
(For example, if ac chooses students , , , and mc chooses students , , , then it must satisfy .)
However, ac does not know which students mc chooses or what is, so he will give several queries. For each query, you need to answer whether, for the given and the segment chosen by mc, ac can choose another segment that satisfies the requirements above.
Simplified statement:
Given and integers .
There are queries. Each query gives . Determine whether there exists such that for all , .
Input Format
The first line contains two integers , representing the number of students and the number of queries.
The second line contains integers. The -th number represents the ugliness value of the -th student.
The next lines each contain three integers , representing the required sum, the index of the first student chosen by mc, and the index of the last student chosen by mc.
Output Format
For each query, if it is possible to choose students that satisfy the conditions, output Yes; otherwise output No. Print one answer per line.
6 4
1 1 3 4 2 1
4 3 3
1 2 2
5 4 6
2 1 2
Yes
No
Yes
Yes
6 4
4 2 2 2 2 1
6 1 1
5 5 6
4 3 5
5 2 2
Yes
No
Yes
No
Hint
Sample Explanation:
For Sample 1:
In the first query, mc chooses the third student, and ac can choose the first student.
In the second query, the ugliness value of the second student chosen by mc is , and the total sum is also , but there is no student with ugliness value , so the condition cannot be satisfied.
In the third query, mc chooses students from the fourth to the sixth. Then ac chooses students from the second to the fourth, and the sums of corresponding positions are , which satisfies the condition.
In the fourth query, mc chooses the first and second students, and ac also chooses the first and second students, so the condition is satisfied.
Constraints:
This problem uses bundled testdata.
For all testdata, , , , .
- Subtask 0 (10 points): .
- Subtask 1 (20 points): .
- Subtask 2 (20 points): All are guaranteed to be the same.
- Subtask 3 (50 points): No special constraints.
Translated by ChatGPT 5