为什么不对啊啊啊啊啊啊啊!第二个样例都过了
#include<bits/stdc++.h>
using namespace std;
int n,m,vis[205][205],cnt=0;
char ch[205][205];
void dfs(int x,int y,int xx,int yy)
{
//cout<<x<<" "<<y<<"\n";
if(x<1||x>n||y<1||y>m)return;
if(vis[x][y]>10)return;
if(ch[x][y]=='#')
{
x-=xx;
y-=yy;
if(xx!=0&&yy!=1&&ch[x][y+1]=='.')dfs(x,y+1,0,1);
if(xx!=0&&yy!=-1&&ch[x][y-1]=='.')dfs(x,y,0,-1);
if(xx!=1&&yy!=0&&ch[x+1][y]=='.')dfs(x+1,y,1,0);
if(xx!=-1&&yy!=0&&ch[x-1][y]=='.')dfs(x-1,y,-1,0);
}
else
{
vis[x][y]++;
dfs(x+xx,y+yy,xx,yy);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>ch[i][j];
}
}
dfs(2,2,0,1);
dfs(2,2,0,-1);
dfs(2,2,1,0);
dfs(2,2,-1,0);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(vis[i][j]>0)
{
//cout<<i<<" "<<j<<"\n";
cnt++;
}
}
}
cout<<cnt;
return 0;
}