#P3674. 小清新人渣的本愿

    ID: 2670 远端评测题 3000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>莫队洛谷原创O2优化枚举,暴力洛谷月赛

小清新人渣的本愿

Description

The problem is as follows:

You are given a sequence aa of length nn, with mm operations. Each operation asks whether, in a given interval, you can choose two numbers whose difference equals xx, or two numbers whose sum equals xx, or two numbers whose product equals xx. These three operations correspond to operations 1,2,31, 2, 3, respectively.

The two chosen numbers may come from the same position.

Input Format

The first line contains two numbers n,mn, m.

The second line contains nn numbers representing aia_i.

Each of the next mm lines contains four numbers opt l r x.

optopt indicates which operation it is, l,rl, r specify the interval, and xx is the value for this operation.

Output Format

For each query, if it is possible, output hana; otherwise, output bi.

10 10
1 1 8 9 9 1 1 1 1 9 
3 5 9 42
2 1 3 14
2 3 5 2
2 3 3 6
1 6 10 18
3 4 9 14
2 1 4 22
3 1 3 32
2 5 6 32
3 1 9 17
bi
bi
bi
bi
bi
bi
bi
bi
bi
bi

5 5
1 1 2 3 4
2 1 1 2
1 1 2 2
3 1 1 1
3 5 5 16
1 2 3 4
hana
bi
hana
hana
bi

Hint

Define cc as the maximum of each xx and all aia_i. Assume ai0a_i \geq 0 and each x0x \geq 0.

For 10%10\% of the testdata, n,m,c100n, m, c \leq 100.

For another 10%10\% of the testdata, n,m,c3×103n, m, c \leq 3 \times 10^3.

For another 10%10\% of the testdata, only operation 11 appears.

For another 10%10\% of the testdata, only operation 22 appears.

For another 10%10\% of the testdata, only operation 33 appears.

For 100%100\% of the testdata, n,m,c105n, m, c \leq 10^5.

Translated by ChatGPT 5