#P7811. [JRKSJ R2] 你的名字。

    ID: 6535 远端评测题 1000ms 128~256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2021洛谷原创O2优化分治块状链表,块状数组,分块st表,稀疏表

[JRKSJ R2] 你的名字。

Description

You are given a sequence aa of length nn. There are mm queries. For each query, you need to find the minimum value in the interval [l,r][l,r] under modulo kk, i.e., min{aimodklir}\min\{a_i \bmod k \mid l \le i \le r\}.

Input Format

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

The second line contains nn integers representing aa.

The next mm lines each contain three integers l,r,kl,r,k, representing one query.

Output Format

For each query, output one answer per line.

10 10
15 14 14 4 8 10 18 14 10 9 
2 10 8
2 4 7
3 9 6
1 7 5
3 4 6
6 6 12
4 8 20
1 6 18
7 8 8
2 6 6
0
0
0
0
2
10
4
4
2
2
5 5
77 24 80 90 92 
2 3 84
4 5 37
1 1 4
3 5 85
1 4 46
24
16
1
5
24

Hint

Idea: mcyl35, Solution: mcyl35, Code: mcyl35, Data: cyffff & mcyl35.

This problem uses bundled testdata.

Subtask\text{Subtask} n,mn,m\le k,aik,a_i\le Special properties Score Dependency
1\text{1} 10410^4 10510^5 None 33 11
2\text{2} 10510^5 300300 66
3\text{3} 10510^5 k103k\ge 10^3 1010 121\to2
4\text{4} None 1919 242\to4
5\text{5} 3×1053\times10^5 Random testdata 1414 11
6\text{6} k103k\ge 10^3 22 232\to3
7\text{7} None 4646 252\to5

Constraints: for 100%100\% of the testdata, 1n,m3×1051\le n,m\le3\times10^5, 1ai,k1051\le a_i,k\le 10^5.

The memory limit for the first 66 subtasks is 256MB256\text{MB}, and the memory limit for the 77th subtask is 128MB128\text{MB}.

Translated by ChatGPT 5