hdu 1728

#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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值