#P8572. [JRKSJ R6] Eltaw

    ID: 9468 远端评测题 2000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2022洛谷原创O2优化枚举前缀和根号分治

[JRKSJ R6] Eltaw

Background

As you walk alone under the moon, you cannot help but think of an easy problem.

(The background image is from a Phigros illustration. If there is any infringement, please inform the problem setter.)

Problem Description

You are given kk sequences a1k,1na_{1\dots k,1\dots n}, each of length nn. There are qq queries. Each query gives an interval [l,r][l,r], and you need to compute maxi=1kj=lrai,j\displaystyle\max_{i=1}^k\sum_{j=l}^ra_{i,j}, i.e., the maximum interval sum over [l,r][l,r] among all sequences.

Input Format

The first line contains three integers n,k,qn,k,q.
Then follow kk lines, each containing nn integers ai,ja_{i,j}.
Then follow qq lines, each containing two integers l,rl,r representing one query.

Output Format

Output qq lines, each representing the answer to one query.

7 2 3
1 1 4 5 1 4 0
1 9 1 9 8 1 0
6 7
5 7
1 3
4
9
11

Hint

Idea: cyffff, Solution: cyffff, Code: cyffff, Data: cyffff

Eltaw - Fl00t (IN Lv 14.8)

The input and output files of this problem are large. Please use appropriate input/output methods.

Constraints

This problem uses bundled testdata.

Subtask\text{Subtask} nn\le Special Constraints Score\text{Score}
11 5×1035\times10^3 k100k\le 100 2020
22 5×1055\times10^5 Guaranteed l=1l=1 3030
33 None 5050

For 100%100\% of the data: 1n,k,q5×1051\le n,k,q\le5\times 10^5, n×k5×105n\times k\le 5\times10^5, 1lrn1\le l\le r\le n, 0ai,j1090\le a_{i,j}\le 10^9.

Data Update Log

Upd 2022.10.05\text{Upd 2022.10.05}: Updated two sets of testdata, which invalidated two incorrect solutions with wrong time complexity. Thanks to

https://www.luogu.com.cn/user/270854

Upd 2022.10.08\text{Upd 2022.10.08}: Updated one set of testdata, which invalidated an incorrect memoization-based solution. Thanks to

https://www.luogu.com.cn/user/236862

If you can pass all current test points, then the complexity of your code is very likely correct. If you still think your complexity is wrong, please contact the problem setter.

Translated by ChatGPT 5