#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
using namespace std;
struct P
{
int i,j;
P(int ii,int jj){i =ii;j=jj;}
};
char map[105][105];
int n,m;
int to;
int dist[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int x,y,xx,yy;
int dp[105][105];
deque<P> G;
deque<P>GG;
void deall(P a,int ii)
{
int x=a.i;
int y=a.j;
for(int i=x-1;i>=0&&map[i][y]=='.';i--)//上
if(dp[i][y]==-1)
{dp[i][y] = ii;GG.push_back(P(i,y));}
for(int i=x+1;i<n&&map[i][y]=='.';i++) //下
if(dp[i][y]==-1)
{dp[i][y] = ii;GG.push_back(P(i,y));}
for(int i=y-1;y>=0&&map[x][i]=='.';i--) //左
if(dp[x][i]==-1)
{dp[x][i] = ii;GG.push_back(P(x,i));}
for(int i=y+1;y<m&&map[x][i]=='.';i++) //右
if(dp[x][i]==-1)
{dp[x][i] = ii;GG.push_back(P(x,i));}
return ;
}
bool dealwith(int x,int y)
{
GG.clear();
GG.push_back(P(x,y));
for(int i=0;i<=to;i++)
{
G = GG;
GG.clear();
while(!G.empty())
{
P temp = G.front();G.pop_front();
deall(temp,i);
}
if(dp[yy-1][xx-1]!=-1) return true;
}
return false;
}
int main()
{
int test;
scanf("%d",&test);
while(test--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
dp[i][j] = -1;
for(int i=0;i<n;i++)
scanf("%s",map[i]);
scanf("%d%d%d%d%d",&to,&x,&y,&xx,&yy);
if(map[y-1][x-1]=='*'||map[yy-1][xx-1]=='*')puts("no");
else{
dp[y-1][x-1] = 0;
if(dealwith(y-1,x-1)) puts("yes");
else puts("no");
}
}
return 0;
}
hdu 1728
最新推荐文章于 2020-02-10 21:10:31 发布