Codeforces Round 981 (Div. 3) |
---|
Finished |
During her journey with Kosuke, Sakurako and Kosuke found a valley that can be represented as a matrix of size $$$n \times n$$$, where at the intersection of the $$$i$$$-th row and the $$$j$$$-th column is a mountain with a height of $$$a_{i,j}$$$. If $$$a_{i,j} < 0$$$, then there is a lake there.
Kosuke is very afraid of water, so Sakurako needs to help him:
More formally, she can choose a submatrix with the upper left corner located at $$$(i, j)$$$ and the lower right corner at $$$(p, q)$$$, such that $$$p-i=q-j$$$. She can then add one to each element at the intersection of the $$$(i + k)$$$-th row and the $$$(j + k)$$$-th column, for all $$$k$$$ such that $$$0 \le k \le p-i$$$.
Determine the minimum number of times Sakurako must use her magic so that there are no lakes.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases.
Each test case is described as follows:
It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$1000$$$.
For each test case, output the minimum number of times Sakurako will have to use her magic so that all lakes disappear.
4112-1 23 031 2 3-2 1 -10 0 -151 1 -1 -1 3-3 1 4 4 -4-1 -1 3 0 -54 5 3 -3 -13 1 -3 -1 5
0 1 4 19
Name |
---|