An Animal Contest 1 P4 - Alpaca Arrays

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 0.75s
Java 2.0s
Python 2.0s
Memory limit: 256M

Authors:
Problem types

Today, Tony the Alpaca needs some help with an array he found in the grass!

Tony gives you an array a of length N. He has Q queries to ask you about the array. Each query is of the form li, ri, xi, such that liri.

Given these parameters, Tony wants to know if there are 2 distinct indices p and q between li and ri inclusive such that apaq=xi.

Also, since Tony hates numbers that are the same, ap must not be equal to aq. To keep Tony happy, you must answer all his queries!

Constraints

1N106

1Q5104

1ai105

1liriN

1xi105

Subtask 1 [10%]

1N,Q,ai103

Subtask 2 [90%]

No additional constraints.

Input Specification

The first line of input contains two integers N and Q.

The second line of input contains N integers ai.

The final Q lines will each contain li,ri,xi, the parameters for the ith query.

Output Specification

For each query, output YES if there are two distinct indices that multiply to xi, and NO otherwise.

Sample Input 1

Copy
5 3
1 5 5 2 3
1 3 25
1 4 6
1 5 10

Sample Output 1

Copy
NO
NO
YES

Sample Input 2

Copy
6 4
2 4 2 4 2 4
1 3 8
1 6 5
1 2 1
1 5 16

Sample Output 2

Copy
YES
NO
NO
NO

Comments

There are no comments at the moment.