[Cpp]
// HDOJ 4414 Finding crosses search
/*
Question: How many cross numbers are shown in a figure?
The definition of a cross is composed of '#' and the size of the cross is greater than or equal to 3, and '#' cannot appear in its adjacent position (horizontal or vertical)
For details, refer to the question
Idea: enumerate the midpoint and find the number of '#' that can be extended in the four directions. time complexity O (n ^ 3)
*/
# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>
# Define INF 100000000
# Define N 55
Int n; www.2cto.com
Char map [N] [N];
Bool check (int x, int y ){
If (x> = 0 & x <n & y> = 0 & y <n)
Return true;
Return false;
}
Int Min (int x, int y ){
Return x <y? X: y;
}
Bool bx (int x, int y ){
Int I, j, xx, yy;
Int a = 1, B = 1, c = 1, d = 1;
Bool aa = false, bb = false, cc = false, dd = false;
For (I = 1; a = I; ++ I ){
Yy = y-I;
If (check (x, yy) & map [x] [yy] = '#')
If (! Check (x + 1, yy) | (check (x + 1, yy) & map [x + 1] [yy]! = '#'))
If (! Check (x-1, yy) | (check (x-1, yy) & map [x-1] [yy]! = '#'))
+ A; aa = true;
}
For (I = 1; B = I; ++ I ){
Yy = y + I;
If (check (x, yy) & map [x] [yy] = '#')
If (! Check (x + 1, yy) | (check (x + 1, yy) & map [x + 1] [yy]! = '#'))
If (! Check (x-1, yy) | (check (x-1, yy) & map [x-1] [yy]! = '#'))
+ + B, bb = true;
}
For (I = 1; c = I; ++ I ){
Xx = x-I;
If (check (xx, y) & map [xx] [y] = '#')
If (! Check (xx, y + 1) | (check (xx, y + 1) & map [xx] [y + 1]! = '#'))
If (! Check (xx, Y-1) | (check (xx, Y-1) & map [xx] [Y-1]! = '#'))
++ C, cc = true;
}
For (I = 1; d = I; ++ I ){
Xx = x + I;
If (check (xx, y) & map [xx] [y] = '#')
If (! Check (xx, y + 1) | (check (xx, y + 1) & map [xx] [y + 1]! = '#'))
If (! Check (xx, Y-1) | (check (xx, Y-1) & map [xx] [Y-1]! = '#'))
++ D, dd = true;
}
Return a = B & B = c & c = d & aa & bb & cc & dd;
}
Int cal (){
Int I, j, ans = 0;
For (I = 0; I <n; ++ I ){
For (j = 0; j <n; ++ j)
If (map [I] [j] = '#' & bx (I, j ))
++ Ans;
}
Return ans;
}
Int main (){
Int I;
While (scanf ("% d", & n), n ){
For (I = 0; I <n; ++ I)
Scanf ("% s", map [I]);
Printf ("% d \ n", cal ());
}
Return 0;
}