emmm,和我的风格不是很像
等一下哈
by sun_fish @ 2022-07-25 10:28:12
@[guoyibo](/user/757355)
by sun_fish @ 2022-07-25 10:28:56
@[guoyibo](/user/757355) 错的点是TLE还是WA
by doc_kaisit @ 2022-07-25 10:37:03
@[doc_kaisit](/user/690149) wa
by sun_fish @ 2022-07-25 10:43:07
```
#include<bits/stdc++.h>
using namespace std;
int map1[6][6];
int visit[6][6];
int n,m,t,cnt;
int sx,sy,tx,ty;
void dfs(int x,int y){
if(x==tx and y==ty){
cnt++;
return;
}
else{
int xx=x-1,yy=y;
if(map1[xx][yy] and !visit[xx][yy]){
visit[xx][yy] = 1;
dfs(xx,yy);
visit[xx][yy] = 0;
}
xx=x;yy=y+1;
if(map1[xx][yy] and !visit[xx][yy]){
visit[xx][yy] = 1;
dfs(xx,yy);
visit[xx][yy] = 0;
}
xx=x+1;yy=y;
if(map1[xx][yy] and !visit[xx][yy]){
visit[xx][yy] = 1;
dfs(xx,yy);
visit[xx][yy] = 0;
}
xx=x;yy=y-1;
if(map1[xx][yy] and !visit[xx][yy]){
visit[xx][yy] = 1;
dfs(xx,yy);
visit[xx][yy] = 0;
}
}
}
int main(){
cin>>n>>m>>t;
cin>>sx>>sy>>tx>>ty;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
map1[i][j]=1;
for(int i=1;i<=t;i++){
int x,y;
cin>>x>>y;
map1[x][y] = 0;
}
map1[sx][sy]=0;
dfs(sx,sy);
cout<<cnt;
return 0;
}
```
by sun_fish @ 2022-07-25 10:51:01
ac 如上
@[guoyibo](/user/757355)
by sun_fish @ 2022-07-25 10:51:51
@[guoyibo](/user/757355) 其实就是把第九行的
int xx=0,yy=0;
移到函数中 int xx=x-1,yy=y;
by sun_fish @ 2022-07-25 10:54:13
@[guoyibo](/user/757355) 活着请回话
by sun_fish @ 2022-07-25 10:55:01
@[guoyibo](/user/757355)
在
```cpp
for(int i=1;i<=t;i++){
int x,y;
cin>>x>>y;
map1[x][y] = 1;
}
```
后面加上
```cpp
if(sz[sx][sy]==1||sz[tx][ty]==1)
{
cout<<0<<endl;
return 0;
}
```
因数据未保证终点处无障碍,故需要进行特判。
by Powerful_25 @ 2022-07-25 10:55:47
@[sun_fish](/user/575822) 感谢大佬,AC了
by guoyibo @ 2022-07-25 11:17:00