hdu1728

/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, m, flag;
int k, x1, x2, y1, y2;
char s[105][105];
int dist[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};

struct node{
    int x, y, w;
    bool operator <(const node &a) const {
        return w > a.w;
    }
};

void bfs(){
    int vis[105][105];
    memset(vis, 0, sizeof(vis));
    priority_queue<node> q;
    q.push(node{x1, y1, -1});
    while(q.size()){
        node t = q.top();
        q.pop();
        //if(t.x == x2 && t.y == y2){
        //    if(t.w <= k){
        //        printf("yes\n");
            //    flag = 1;
            //}
        //    return ;
        //}
        for (int i = 0; i < 4; i++){
            int x = t.x + dist[i][0], y = t.y + dist[i][1];
            while(!(x < 1 || x > n || y < 1 || y > m || s[x][y] == '*')){
                if(!vis[x][y] || vis[x][y] > t.w + 1){
                    vis[x][y] = t.w + 1;
                    q.push(node{x, y, t.w + 1});
                    if(x == x2 && y == y2 && t.w + 1 <= k){
                        printf("yes\n");
                        flag = 1;
                        return ;
                    }
                }
                x += dist[i][0], y += dist[i][1];
            }
            
        }
    }
}

int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        scanf("%d %d", &n, &m);
        for (int i = 1; i <= n; i++){
            scanf("%s", s[i] + 1);
        }
        scanf("%d %d %d %d %d",&k, &y1, &x1, &y2, &x2);
        if(s[x2][y2] == '*'){
            printf("no\n");
            continue;
        }
        flag = 0;
        bfs();
        if(!flag){
            printf("no\n");
        }
    }
    return 0;
}
/**/

注意行和列反过来!!多坑啊

全部评论

相关推荐

来个厂收我吧:首先,市场侧求职我不是很懂。 但是,如果hr把这份简历给我,我会觉得求职人不适合做产品经理。 问题点: 1,简历的字体格式不统一,排版不尽如人意 2,重点不突出,建议参考star法则写个人经历 3,印尼官方货币名称为印度尼西亚卢比(IDR),且GMV690000印尼盾换算为305人民币,总成交额不高。 4,右上角的意向职位在发给其他公司时记得删除。 5,你所有的经历都是新媒体运营,但是你要投市场营销岗位,jd和简历不匹配,建议用AI+提示词,参照多个jd改一下经历内容。 修改建议: 1,统一字体(中文:思源黑体或微软雅黑,英文数字:time new romans),在word中通过表格进行排版(b站学) 2,校招个人经历权重:实习经历=创业经历(大创另算)>项目经历>实训经历>校园经历 3,请将项目经历时间顺序改为倒序,最新的放最上方。 4,求职方向不同,简历文字描述侧重点也需要不同。
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务