Problem 7: Abstract Painting
https://open.kattis.com/problems/abstractpainting
Color square by square, starting at the top-left square.
To color the top-left square, there are ways to choose the two colors for the square. Then, there are ways to arrange these colors. So, there are ways to color the top-left square.
Next, move right and color the rest of the squares in the first row. For these squares, we'll have already colored the square to the left, which means one line is colored already. So, one color is already fixed, and there are then choices for the second color. Moreover, there are ways to arrange the remaining three lines of the square. So, there are ways to color the squares of the first row. Similarly, there are ways to color the squares of the first column as well.
For the rest of the squares, we can keep coloring squares with two lines already colored, until we have colored the entire painting. For each square with two lines already colored, there are two cases:
Both lines are the same color: there are ways to choose the second color, and only way to color the remaining two lines (both must be the other color). So, there are colorings.
The two lines are different colors: both colors of the square are defined by these two lines. There are ways to color the remaining two lines. So there are colorings.
Therefore, for these squares, there are always colorings.
So, to count the total number of good paintings, start with 18 for the first square. Multiply by 6 for each other square in the first row or first column, and multiply by 2 for every other square. That gives us the expression:
Last updated