Hide

Problem D
John Dillermand

/problems/wcfd21.johndillermand/file/statement/en/img-0001.png
Your university maintains excellent relations with the large public service media company behind John Dillermand, a claymation TV show aimed at four- to eight-year-old children. International reactions to the programme have been mixed, with critics viewing it as sophomoric and tone-deaf at best, a deliberate provocation of public morals or a problematic confirmation of stereotypes at worst. To make the show marketable to audiences more fragile than Danish children it has been decided to clean up the footage by removing the mustachioed protagonist’s prehensile appendage.

For most episodes, this task has been adequately performed by training your university’s machine-learned information curation algorithms to remove red and white pixels from individual frames. However, the Christmas episode S1E11, John redder julen, needs more attention. Many of the scenes involve candy canes, Danish flags, and other Christmas decorations that must be kept for narrative cohesion.

\includegraphics[width=.25\textwidth ]{img/sample1.jpg}

It turns out that removing only John Dillermand’s eponymous protuberance from these frames requires a lot more delicacy than what deep learning can provide. Instead of editing every frame manually, you decide to write a plug-in to the image processing software that automates this task.

Input

The input represents a single image of the episode, called a frame. On the first line, the frame’s dimensions as two space-separated integers $h$ and $w$. Then follow $h$ lines of $w$ symbols, each representing a pixel, with “#” meaning red, “O” meaning white, and “.” meaning anything else. The top left corner is guaranteed to be either white or red and is an endpoint of John’s appendage. The appendage is one pixel wide, alternates between red and white neighbouring pixels, and does neither touch nor intersect itself, nor does it touch other red or white pixels in the frame. Two pixels are considered touching if they share a horizontal or vertical side.

Output

Print $h$ lines of $w$ symbols: The improved frame, where the pixels that make up John’s appendage have been replaced by “.”. No other pixels may be changed.

Sample Input 1 Sample Output 1
20 20
O.#O#O#O#O#O........
#...........#.......
O...........O.......
#.........O#........
O...................
#O#O#O#......#......
......O......#......
......#....#.#.#....
......O...#######...
...O#O#...#O#O#O#...
...#.......#O#O#....
...O#O......#O#.....
.....#O#.....#......
................O#..
...............#..O.
.##O####..........#.
.##O####.........O..
.OOOOOOO........#...
.##O####.......O....
.##O####......#.....
..#O#O#O#O#O........
............#.......
............O.......
..........O#........
....................
.............#......
.............#......
...........#.#.#....
..........#######...
..........#O#O#O#...
...........#O#O#....
............#O#.....
.............#......
................O#..
...............#..O.
.##O####..........#.
.##O####.........O..
.OOOOOOO........#...
.##O####.......O....
.##O####......#.....
Sample Input 2 Sample Output 2
4 5
#....
O....
...#O
...O#
.....
.....
...#O
...O#
Sample Input 3 Sample Output 3
2 2
#.
.O
..
.O
Sample Input 4 Sample Output 4
2 2
#.
O#
..
..
Sample Input 5 Sample Output 5
1 1
O
.

Please log in to submit a solution to this problem

Log in