#P7899. [Ynoi2006] rprmq2
[Ynoi2006] rprmq2
Problem Description
Given a positive integer , you need to maintain an matrix , with initial values all .
There are operations. Each operation gives .
First, for each , query the maximum value of among all positions in the matrix that satisfy . Denote the answer as .
Then, for every position in the matrix, add to .
The notation equals when the condition is true, and otherwise.
Input Format
The first line contains one positive integer .
Then follow lines. Each line contains numbers representing one operation, with the meaning described above.
Output Format
For each operation, output lines, in order: .
10
2 8 9 5 4 2
7 10 3 7 2 10
10 5 4 2 8 3
8 8 7 6 8 4
3 2 5 3 2 9
3 3 9 10 5 6
4 8 2 9 3 2
4 5 5 10 1 1
9 4 10 2 1 4
6 9 7 2 4 6
0
0
0
0
9
5
4
2
12
12
6
12
16
14
14
15
23
23
22
22
28
26
31
31
37
33
37
35
39
42
40
37
44
52
41
41
54
54
47
41
Hint
Idea: ?, Solution: ?, Code: ccz181078, Data: ccz181078.
For of the testdata, , , and all values are integers.
Translated by ChatGPT 5