#include<cstdio>struct node{int x, y;node(){}node(constint&xx,constint&yy){
x = xx, y = yy;}} a[10005];char map[105][105];int n, m, begin, end, walk[8][2]={{-1,-1},{1,1},{-1,1},{1,-1},{1,0},{0,1},{-1,0},{0,-1}};boolpd(constint&x,constint&y){return(x >=0&& y >=0& x < n && y < m);}voidbfs(constint&x,constint&y);intmain(){freopen("cpp.in","r",stdin);freopen("cpp.out","w",stdout);scanf("%d%d",&n,&m);for(int i =0; i < n;++i){scanf("%s",&map[i]);}int ans =0;for(int i =0; i < n;++i){for(int j =0; j < m;++j){if(map[i][j]=='W'){bfs(i, j);++ans;}}}printf("%d", ans);return0;}voidbfs(constint&x,constint&y){
begin = end =1;
map[x][y]='#';
a[end++]=node(x, y);while(begin != end){
node now = a[begin++];for(int i =0; i <8;++i){int nx = now.x + walk[i][0];int ny = now.y + walk[i][1];if(pd(nx, ny)&& map[nx][ny]=='W'){
a[end++]=node(nx, ny);
map[nx][ny]='#';}}}}
【题目】:https://www.luogu.com.cn/problem/P1596#include <cstdio>struct node{ int x, y; node(){ } node(const int &xx, const int &yy) { x = xx, y = yy; }} a[10005];char map[105][10...