Problem H
Don't Fence Me In

Given an orthogonal maze rotated
/\ \/
This maze has only a single region fully enclosed. Removing any wall connects it to the outside.
/\.. \.\. .\/\ ..\/
This maze has two enclosed areas. Two walls need to be removed to connect all regions to the outside.
Input
The first line has two numbers,
Define an odd (even) square as one where the sum of the
Output
Output on a single line an integer indicating how many walls need to be removed so escape is possible from every region in the maze.
Sample Input 1 | Sample Output 1 |
---|---|
2 2 /\ \/ |
1 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 /\.. \.\. .\/\ ..\/ |
2 |
Sample Input 3 | Sample Output 3 |
---|---|
2 2 \/ /\ |
0 |
Sample Input 4 | Sample Output 4 |
---|---|
8 20 /\/\/\/\/\/\/\/\/\/\ \../\.\/./././\/\/\/ /./\.././\/\.\/\/\/\ \/\/\.\/\/./\/..\../ /\/./\/\/./..\/\/..\ \.\.././\.\/\/./\.\/ /.../\../..\/./.../\ \/\/\/\/\/\/\/\/\/\/ |
26 |