P7899 [Ynoi2006] rprmq2
Description
Given a positive integer $m$, you need to maintain an $m \times m$ matrix $a_{i,j},\;1\le i,j\le m$, with initial values all $0$.
There are $m$ operations. Each operation gives $x,\;y,\;z_{0,0},\;z_{0,1},\;z_{1,0},\;z_{1,1}$.
First, for each $0\le p,q\le 1$, query the maximum value of $a_{i,j}$ among all positions in the matrix that satisfy $[i\ge x]=p,\;[j\ge y]=q$. Denote the answer as $w_{p,q}$.
Then, for every position $(i,j)$ in the matrix, add $z_{[i\ge x],[j\ge y]}$ to $a_{i,j}$.
The notation $[c]$ equals $1$ when the condition $c$ is true, and $0$ otherwise.
Input Format
The first line contains one positive integer $m$.
Then follow $m$ lines. Each line contains $6$ numbers $x,\;y,\;z_{0,0},\;z_{0,1},\;z_{1,0},\;z_{1,1}$ representing one operation, with the meaning described above.
Output Format
For each operation, output $4$ lines, in order:
$w_{0,0},\;w_{0,1},\;w_{1,0},\;w_{1,1}$.
Explanation/Hint
Idea: ?, Solution: ?, Code: ccz181078, Data: ccz181078.
For $100\%$ of the testdata, $2 \le x,y\le m\le 2\times 10^5$, $1\le z_{i,j}\le 10^9$, and all values are integers.
Translated by ChatGPT 5