~~类型定义纯属在乱搞啊~~
by xQAQyn @ 2019-06-03 06:36:33
把scanf改成cin?
by lzx1999 @ 2019-06-03 08:17:21
你难道没有信息学奥赛一本通吗?
有的话可以看一下广搜那一章
@[leprechaun_kdl](/space/show?uid=156924)
by momentous @ 2019-06-03 08:33:55
还有,你不怕开register long long 寄存器爆炸吗?
by momentous @ 2019-06-03 08:35:11
@[leprechaun_kdl](/space/show?uid=156924)
正解不是```广搜```吗,干嘛用```深搜```做。
~~虽然也可以~~
by momentous @ 2019-06-03 08:36:48
不过,对于您的定义......
本蒟蒻只能Orz
by momentous @ 2019-06-03 08:37:52
硬核输入字符串?
by ErkkiErkko @ 2019-06-03 08:40:32
```signed main()```
有什么用吗?
by momentous @ 2019-06-03 08:40:48
```
#include<bits/stdc++.h>
using namespace std;
int m,n,tot;
int a[105][105];
bool vis[105][105];
int wayx[4]={-1,0,1,0};
int wayy[4]={0,-1,0,1};
void dfs(int x,int y,int t)
{
vis[x][y]=1;
for(int i=0;i<4;i++)
{
if(x+wayx[i]>0 && x+wayx[i]<n+1 && y+wayy[i]>0 && y+wayy[i]<m+1 && vis[x+wayx[i]][y+wayy[i]]==0 && a[x+wayx[i]][y+wayy[i]]!=0)
dfs(x+wayx[i],y+wayy[i],t);
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%1d",&a[i][j]);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if(a[i][j]==0) continue;
if(vis[i][j]==1) continue;
tot++;
dfs(i,j,tot);
}
printf("%d\n",tot);
return 0;
}
```
by momentous @ 2019-06-03 08:53:48
调好了
@[leprechaun_kdl](/space/show?uid=156924)
by momentous @ 2019-06-03 08:54:07