Skip to content

Commit e2f3f37

Browse files
Update cses-1148.mdx
1 parent bc0ba8a commit e2f3f37

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

solutions/gold/cses-1148.mdx

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ author: Mihnea Brebenel
77

88
## Explanation
99

10-
Precompute $r_{i,j}$ as the maximum number of continuous free cells on line $i$ starting from $(i, j)$ to the right.
11-
Similarly to [Maximum Building I](https://cses.fi/problemset/task/1147) apply monotonic stacks to find:
12-
- $u_{i, j}$ , the last line above $i$ with cell $(x, j)$ such that $r_{x, j} > r_{i, j}$
13-
- $d_{i, j}$ , the last line under $i$ with cell $(y, j)$ such that $r_{y, j} \ge r_{i, j}$
10+
Let $r_{i,j}$ be the maximum number of continuous free cells on line $i$ starting from $(i, j)$ to the right.
11+
This can be precomputed.
12+
Similarly to [Maximum Building I](https://cses.fi/problemset/task/1147), we can also apply monotonic stacks to find
13+
1. $u_{i, j}$, the last line above $i$ with cell $(x, j)$ such that $r_{x, j} > r_{i, j}$
14+
2. $d_{i, j}$, the last line under $i$ with cell $(y, j)$ such that $r_{y, j} \ge r_{i, j}$
1415

1516
We can efficiently update the answer matrix with [prefix sums](/silver/more-prefix-sums#2d-prefix-sums)
1617
and [difference arrays](https://codeforces.com/blog/entry/78762).

0 commit comments

Comments
 (0)