#P12410. Arithmetic Progression Subarray Queries

    ID: 14513 Type: Default 1000ms 256MiB

Arithmetic Progression Subarray Queries

Arithmetic Progression Subarray Queries

You are given a sequence \(c\) of \(n\) integers and \(m\) queries. Each query is given in the format:

l r x y a b

For a query, you need to determine whether the subarray \(c_l, c_{l+1}, \ldots, c_r\) contains every number of the form \(ka+b\) (with \(k\) an integer) that lies in the interval \([x,y]\). In other words, for every integer \(k\) such that \(x \leq ka+b \leq y\), the number \(ka+b\) must appear at least once in the subarray.

Note: If \(a=0\) and \(b\) is in \([x,y]\), then \(b\) must appear at least once; if \(b\) is not in \([x,y]\) the condition is considered satisfied.

inputFormat

The first line contains two integers \(n\) and \(m\) — the length of the sequence and the number of queries.

The second line contains \(n\) space-separated integers \(c_1, c_2, \ldots, c_n\) representing the sequence.

Then \(m\) lines follow, each containing six integers: \(l\), \(r\), \(x\), \(y\), \(a\), and \(b\), describing a query.

outputFormat

For each query, output a single line containing either Yes if the subarray meets the condition, or No otherwise.

sample

5 3
1 2 3 4 5
1 5 1 5 1 0
2 4 2 4 2 0
2 4 1 5 2 0
Yes

Yes Yes

</p>