#include<stdio.h>
int n,m;
char field[1000][1000];
int dx,dy,nx,ny,res;
void dfs(int x,int y )
{
field[x][y]='.';
for(dx=-1;dx<=1;dx++)
{
for(dy=-1;dy<=1;dy++)
{
nx=dx+x;
ny=dy+y;
if(0<=nx&&nx<n&&0<=ny&&ny<m&&field[nx][ny]=='W')dfs(nx,ny);
}
}
}
int main()
{
int i,j;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
getchar();
for(j=0;j<m;j++)
{
scanf("%c",&field[i][j]);
}
}
res=0;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(field[i][j]=='W')
{
dfs(i,j);
res++;
}
}
}
printf("%d\n",res);
return 0;
}
poj 2386这都题 这么做 哪里错了? 求大神指点
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
悬赏问题
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作