记忆化搜索。dp[0] 向左 dp[1] 向右 dp[2] 表示这个点能够满足条件
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
char map[2005][2005];
int step[4][2]={
{
1,0},{
0,1},{
-1,0},{
0,-1}};
int vist[2005][2005];
int dp[2005][2005][3];
int n,m;
struct node{
int x;
int y;
int r;
int l;
};
node star;
int judge(int x,int y,int l,int r){
if(x>=1&&x<=n&&y>=1&&y<=m&&vist[x][y]){
if(dp[x][y][0]<l||dp[x][y][1]<r||!dp[x][y][2]){
dp[x][y][0]=l;
dp[x][y][1]=r;
dp[x][y][2]=1;
return 1;
}
}
return 0;
}
void bfs()