SDNU 1507.E.The Binding of Isaac

mac2022-06-30  20

Description

 

Ok, now I will introduce this game to you...

Isaac is trapped in a maze which has many common rooms…

Like this…There are 9 common rooms on the map.

 

And there is only one super-secret room. We can’t see it on the map. The super-secret room always has many special items in it. Isaac wants to find it but he doesn’t know where it is.Bob  tells him that the super-secret room is located in an empty place which is adjacent to only one common rooms.  Two rooms are called adjacent only if they share an edge. But there will be many possible places.

 

Now Isaac wants you to help him to find how many places may be the super-secret room.

Input

Multiple test cases. The first line contains an integer T (T<=3000), indicating the number of test case. Each test case begins with a line containing two integers N and M (N<=100, M<=100) indicating the number of rows and columns. N lines follow, “#” represent a common room. “.” represent an empty place.Common rooms  maybe not connect. Don’t worry, Isaac can teleport.

Output

 One line per case. The number of places which may be the super-secret room.

Sample Input

2 5 3 ..# .## ##. .## ##. 1 1 #

Sample Output

8 4 /// /// _ooOoo_ /// o8888888o /// 88" . "88 /// (| -_- |) /// O\ = /O /// ____/`---'\____ /// .' \\| |// `. /// / \\||| : |||// \ /// / _||||| -:- |||||- \ /// | | \\\ - /// | | /// | \_| ''\---/'' | | /// \ .-\__ `-` ___/-. / /// ___`. .' /--.--\ `. . __ /// ."" '< `.___\_<|>_/___.' >'"". /// | | : `- \`.;`\ _ /`;.`/ - ` : | | /// \ \ `-. \_ __\ /__ _/ .-` / / /// ======`-.____`-.___\_____/___.-`____.-'====== /// `=---=' /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /// Buddha Bless, No Bug ! /// #include <cstdio> #include <iostream> #include <string> #include <cstring> #include <cmath> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long const int mod = 1e9+7; int t, n, m, sum, mov[4][2] = {0,1, 0,-1, 1,0, -1,0}; char fig[200+8][200+8]; int main() { for(scanf("%d", &t); t--; ) { scanf("%d%d", &n, &m); getchar(); sum = 0; for(int i = 0; i <= n+1; i++) for(int j = 0; j <= m+1; j++) fig[i][j] = '.'; for(int i = 1; i <= n; i++) { scanf("%s", fig[i]+1); getchar(); } for(int i = 0; i <= n+1; i++)///后来总是无法消去回车键,所以要另外补充 '.' fig[i][m+1] = '.'; for(int i = 0; i <= n+1; i++) { for(int j = 0; j <= m+1; j++) { int num = 0; if(fig[i][j] == '.') { for(int k = 0; k<4; k++) { int buffer_x, buffer_y; buffer_x = i+mov[k][0]; buffer_y = j+mov[k][1]; if(buffer_x >= 0 && buffer_x <= n+1 && buffer_y >= 0 && buffer_y <= m+1 && fig[buffer_x][buffer_y] == '#')num++; } if(num == 1)sum++; } } } printf("%d\n", sum); } return 0; }

 

 

转载于:https://www.cnblogs.com/RootVount/p/11237911.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)