|
2 | 2 | id: usaco-923
|
3 | 3 | source: USACO Gold 2019 February
|
4 | 4 | title: Painting the Barn
|
5 |
| -authors: Kevin Sheng, KJ Karaisz |
| 5 | +author: Kevin Sheng, KJ Karaisz |
6 | 6 | ---
|
7 | 7 |
|
8 | 8 | **Note:** This editorial assumes one already has a firm grasp of the
|
9 | 9 | [silver](http://www.usaco.org/current/data/sol_paintbarn_silver_feb19.html)
|
10 | 10 | version of this problem.
|
11 | 11 |
|
12 | 12 | <Spoiler title="Hint 1">
|
13 |
| -Think about one rectangle for now. |
14 | 13 |
|
15 |
| - <Spoiler title="Hint 1.1"> |
16 |
| - What cells can you ignore? |
17 |
| - </Spoiler> |
18 |
| - |
19 |
| - <Spoiler title="Hint 1.2"> |
20 |
| - What if the problem was one-dimensional? |
21 |
| - </Spoiler> |
| 14 | +Say FJ could only paint one rectangle of paint over the barn. |
| 15 | +Then, this problem would turn into finding the |
| 16 | +[maximum sum of a submatrix](https://stackoverflow.com/a/18220549/12128483). |
22 | 17 |
|
23 | 18 | </Spoiler>
|
24 | 19 |
|
25 | 20 | <Spoiler title="Hint 2">
|
| 21 | + |
26 | 22 | So you have your one rectangle now. How do you make this algorithm work for two?
|
27 | 23 |
|
28 |
| - <Spoiler title="Hint 2.1"> |
29 |
| - You could certainly run the algorithm on another rectangle. |
30 |
| - </Spoiler> |
| 24 | +Try to think about how you can guarantee disjoint rectangles! |
| 25 | + |
| 26 | +</Spoiler> |
| 27 | + |
| 28 | +<Spoiler title="Answer to Hint 2"> |
31 | 29 |
|
32 |
| - <Spoiler title="Hint 2.2"> |
33 |
| - *Multiple* rectangles, perhaps? |
34 |
| - </Spoiler> |
| 30 | +If two rectangles are disjoint, there can always be a horizontal or vertical line separating them. |
35 | 31 |
|
36 | 32 | </Spoiler>
|
37 | 33 |
|
38 | 34 | <Spoiler title="Solution">
|
| 35 | + |
39 | 36 | [Official Analysis (C++)](http://www.usaco.org/current/data/sol_paintbarn_gold_feb19.html)
|
40 | 37 |
|
41 | 38 | ## Explanation
|
|
0 commit comments