Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions solutions/bronze/usaco-737.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@
id: usaco-737
source: USACO Bronze 2017 US Open
title: Modern Art
author: Juheon Rhee, Kevin Sheng, Yifan Ma
author: Juheon Rhee, Kevin Sheng, Yifan Ma, Arnav Gokhale
---

<Spoiler title="Hint">
[Official Analysis (C++)](http://www.usaco.org/current/data/sol_art_bronze_open17.html)

# Solution

<Spoiler title="Hint 1">

Try solving the sample input by hand: could you apply a similar method in your code?

</Spoiler>

[Official Analysis (C++)](http://www.usaco.org/current/data/sol_art_bronze_open17.html)
<Spoiler title="Hint 2">

# Solution
What is a property of a color that cannot be the first painted?

<Spoiler title="Solution">
</Spoiler>

## Explanation

Firstly, notice that if two colors are overlapping, we know at least one of them cannot be the original rectangle.

For each color $c_1$, we can determine the limits of that color and consider it's bounding rectangle. Any other color $c_2$ that appears inside this rectangle in the final grid mutst have been painted after $c_1$, and we can rule out $c_2$ as the first color painted.

We must notice that we always choose the smallest bounding rectangle as possible for each color $c_1$. This is because a larger rectangle creates more intersection between colors, which could elminate valid starting colors.

## Implementation

Expand Down Expand Up @@ -192,5 +204,3 @@ print(sum(valid_start), file=open("art.out", "w"))

</PySection>
</LanguageSection>

</Spoiler>