Skip to content

Commit 0aa660c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d049ec3 commit 0aa660c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

solutions/gold/cses-1148

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Similarly to [Maximum Building I](https://cses.fi/problemset/task/1147) apply mo
1414
- $u_{i, j}$ , the last line above $i$ with cell $(x, j)$ such that $r_{x, j} > r_{i, j}$
1515
- $d_{i, j}$ , the last line under $i$ with cell $(y, j)$ such that $r_{y, j} \ge r_{i, j}$
1616

17-
Using [prefix sums](/silver/more-prefix-sums#2d-prefix-sums) and [difference arrays](https://codeforces.com/blog/entry/78762)
18-
we can efficiently update the answer matrix. Having $r_{i,j}$, $u_{i,j}$ and $d_{i,j}$ precomputed, we know the upperbound
19-
and the lowerbound of the rectangle of of width $r_{i,j}$ i.e. how much it can expand above and below line $i$ maintaing width $r_{i, j}$.
17+
Using [prefix sums](/silver/more-prefix-sums#2d-prefix-sums) and [difference arrays](https://codeforces.com/blog/entry/78762)
18+
we can efficiently update the answer matrix. Having $r_{i,j}$, $u_{i,j}$ and $d_{i,j}$ precomputed, we know the upperbound
19+
and the lowerbound of the rectangle of of width $r_{i,j}$ i.e. how much it can expand above and below line $i$ maintaing width $r_{i, j}$.
2020
We'll do difference arrays on each column independently. Accordingly, the updates of the answer matrix look like this:
2121
- $ans[1][r_{i,j}]++$
2222
- $ans[i - u_{i, j} + 2][r_{i,j}]--$ , the upperbound
@@ -39,7 +39,7 @@ Finally, add $ans[i][j]$ to $ans[i][j-1]$ i.e. a submatrix of size $i \times j$
3939

4040
using namespace std;
4141

42-
int main() {
42+
int main() {
4343
int n, m;
4444
cin >> n >> m;
4545
vector<vector<int>> r(n + 2, vector<int>(m + 2));
@@ -106,4 +106,4 @@ int main() {
106106
```
107107

108108
</CPPSection>
109-
</LanguageSection>
109+
</LanguageSection>

0 commit comments

Comments
 (0)