I found the gap between myself and the world.
At the beginning, I thought about how to simulate this maze. I wanted to search for Daniel online if I had no idea. The result is to replace '\' and '/' with a square, which is the opposite of what I think. But I gave up thinking. Ah, next time I will never do that.
Back to the beginning, we used a 2*2 square to simulate the slash at the beginning, but it was very troublesome to judge the direction of recursion. A total of 8 directions need to be determined. So we used 3*3 to simulate this slash. In this way, you only need to write down the number of squares that have been traversed to get the answer.
Below isCode:
# Include <stdio. h> # include <string. h> # define maxn 100 char map [maxn] [maxn]; int G [maxn * 3] [maxn * 3]; int vis [maxn * 3] [maxn * 3]; int W, H; int CNT; int tag; int sum; int move [4] [2] = {}, {-}, {}, {0,-1}; void DFS (int x, int y) {CNT ++; vis [x] [Y] = 1; int flag = 0; For (INT I = 0; I <4; I ++) {int dx = x + move [I] [0]; int DY = Y + move [I] [1]; if (dx> = 0 & DX <H * 3 & dy> = 0 & dy <w * 3) {If (G [dx] [dy] = 0 &&! Vis [dx] [dy]) DFS (dx, Dy) ;}} void color (int x, int y) // classify the cell in the boundary, the remain cells of all can be a loop {vis [x] [Y] = 1; for (INT I = 0; I <4; I ++) {int dx = x + move [I] [0]; int DY = Y + move [I] [1]; if (dx> = 0 & DX <H * 3 & dy> = 0 & dy <w * 3) {If (G [dx] [dy] = 0 &&! Vis [dx] [dy]) DFS (dx, Dy) ;}} int main () {int T = 0; while (scanf ("% d ", & W, & H) & W & H) {T ++; memset (G, 0, sizeof (g); memset (VIS, 0, sizeof (VIS); For (INT I = 0; I