#P15663. [ICPC 2025 Jakarta R] International Olympiad in ICPC
[ICPC 2025 Jakarta R] International Olympiad in ICPC
题目描述
Your university is hosting a competition called the IOI. As an event organiser, you want to create a banner for it. The banner you are preparing can be represented as a grid, where each cell will be printed either white or black. Due to printing issues, some of the cells cannot be printed in black.
You start with a white banner, and want to print the word on the banner as follows.
- Form the first letter by printing a rectangle of size () in black.
- Form the letter by printing a rectangular of size () in black.
- Form the second letter by printing a rectangle of size () in black.
The letter must be formed between the letters , and there must be one column between the letters. It is also required that the width of the letter is the sum of the widths of the letters , i.e. . All other cells not part of the word must remain white.
Determine the maximum number of cells that you can print in black, or tell that it's impossible to print the word .
输入格式
The first line contains an integer (), the size of the grid.
Each of the next three lines contains characters representing the cells of the grid.
Each of the characters corresponds to a cell and is either or , meaning you can or cannot print the cell in black, respectively.
输出格式
A single line representing the maximum number of cells that you can print in black.
If it's impossible to print the word , output instead.
7
.......
.......
.......
14
6
......
......
......
-1
12
...#....#...
...#.##.#...
...#....#...
22
20
#...##..............
#...##.##....#...#..
#...##..............
39
提示
You can print your banner in the following way.
I.OOO.I
I.O.O.I
I.OOO.I
You can print your banner in the following way.
..I#OOOO#III
..I#O##O#III
..I#OOOO#III
You can print your banner in the following way.
#III##OOOOOOOOOOO.II
#III##O##....#..O#II
#III##OOOOOOOOOOO.II