Remodeling the Dungeon 2
시간 제한8초메모리 제한2048 MB
연결된 격자 그래프인 던전에서 문을 막아 방 사이의 경로가 유일하도록 만들고, 문이 하나뿐인 두 방 사이의 거리가 짝수가 되도록 남은 문을 출력한다. 불가능하면 No를 출력한다.
문제
The Queen of the Kingdom of Icpca resides in a castle peacefully. One day, she decided to remodel the dungeon of the castle.
The dungeon is a rectangular grid consisting of square cells. Some cells are enterable rooms, while others are duct spaces which are not enterable. All pairs of adjacent cells are separated by a wall. Some of the walls between two adjacent rooms are installed with a door to go back and forth. Any pair of rooms in the dungeon has connecting paths through these doors.
The Queen wants to remodel the dungeon so that there is only one unique path between any pair of rooms. Additionally, any pair of rooms both with only one door should be connected with a path going through an even number of doors. Due to the cost limitation, what can be done in the remodeling is only to block some (possibly zero) doors.
Your mission is to find a way to remodel the dungeon as the Queen wants.
입력
The input consists of a single test case in the following format.
Two integers and mean that the dungeon size is . They are between and , inclusive.
Each of the characters (, ) is either ‘.’ or ‘#’. These characters represent the configuration of the dungeon as follows.
- When both and are even, represents the cell located at the -th row from the north and the -th column from the west of the dungeon, referred to as cell . Being ‘
.’ indicates that the cell is a room, while ‘#’ indicates a duct space. - When is odd and is even, it represents a wall. When or , it is a part of the outer wall of the dungeon. In this case, is always ‘
#’. Otherwise, represents the wall between cells and . Being ‘.’ indicates that the wall has a door, while ‘#’ indicates that it does not. Doors are installed only in walls between two rooms. - When is even and is odd, it also represents a wall. When or , it is a part of the outer wall of the dungeon. In this case, is always ‘
#’. Otherwise, represents the wall between cells and . Being ‘.’ indicates that the wall has a door, while ‘#’ indicates that it does not. Doors are installed only in walls between two rooms. - When both and are odd, is always ‘
#’, corresponding to an intersection of walls.
It is guaranteed that there is at least one room in the dungeon and any pair of rooms in the dungeon has one or more connecting paths.
출력
If it is impossible to remodel the dungeon as the Queen wants, output No. Otherwise, output Yes on the first line, followed by the configuration of the dungeon after the remodeling in the same format as the input. If there are multiple possible configurations, any one of them is acceptable.