路径是可以重复走的,但是如果再一次走过时间重置点是没有意义的

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;

;
int mp[N][N];
struct Node {
    int x, y, step, time;
};
int m, n;
][] = {,, ,, -,, ,-};

int bfs(int x, int y) {
    queue<Node> que;
    Node start;
    start.x = x; start.y = y; start.step = ; start.time = ;
    que.push(start);
    while(!que.empty()) {
        Node cur = que.front();
        que.pop();
        )
            continue;
        ; i<; i++) {
            ];
            ];
            Node nextstep;
            nextstep.x = tx; nextstep.y = ty;
            nextstep.step = cur.step+; nextstep.time = cur.time-;
             || ty< || tx>=m || ty>=n) {
                continue;
            }
            ) continue;
            ) {
                )
                    ;
                else
                    continue;
            }
            ) {
                ){
                    nextstep.time = ;
                    mp[tx][ty] = ;         //只能走一次,走多了就没有意义了
                } else {
                    continue;
                }
            }
            que.push(nextstep);
        }
    }
    ;
}
int main()
{
    int t;
    cin>>t;
    while(t--) {
        cin>>m>>n;
        int x, y;
        ; i<m; i++) {
            ; j<n; j++) {
                cin>>mp[i][j];
                ) {
                    x = i; y = j;
                }
            }
        }
        cout<<bfs(x, y)<<endl;
    }
    ;
}

hdu 1072 广搜的更多相关文章

  1. hdu 1072 广搜(逃离爆炸迷宫)

    题意: 在n×m的地图上,0表示墙,1表示空地,2表示人,3表示目的地,4表示有定时炸弹重启器.定时炸弹的时间是6,人走一步所需要的时间是1.每次可以上.下.左.右移动一格.当人走到4时如果炸弹的时间 ...

  2. hdu 1175(广搜)

    题意:容易理解... 思路:我开始的思路不好实现,而且有漏洞,时间复杂度也高,后来在网上学了下别人的方法,真心感觉很牛B,不仅代码好实现,而且时间复杂度比较低,具体看代码实现吧!! 代码实现: #in ...

  3. hdu 1180(广搜好题)

    诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Subm ...

  4. HDU 1072 Nightmare (广搜)

    题目链接 Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a ...

  5. hdu 1195:Open the Lock(暴力BFS广搜)

    Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. hdu 5025 Saving Tang Monk 状态压缩dp+广搜

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092939.html 题目链接:hdu 5025 Saving Tang Monk 状态压缩 ...

  7. hdu 5094 Maze 状态压缩dp+广搜

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092176.html 题目链接:hdu 5094 Maze 状态压缩dp+广搜 使用广度优先 ...

  8. hdu 1253:胜利大逃亡(基础广搜BFS)

    胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  9. hdu 2717:Catch That Cow(bfs广搜,经典题,一维数组搜索)

    Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

随机推荐

  1. nginx如何配置网页错误页面

    首先要在http模块中加入 fastcgi_intercept_errors on; 其次要在server模块中加入 error_page 403 404 /40x.html; location = ...

  2. js 中的 exec( )方法

    JavaScript exec() 方法 JavaScript RegExp 对象 定义和用法 exec() 方法用于检索字符串中的正则表达式的匹配. 语法:RegExpObject.exec(str ...

  3. MariaDB数据解压版安装(10.0.16)

    官网下载地址:https://downloads.mariadb.org/    (自己选择版本下载) 在windows 7 下安装 1.下载到解压版安装文件mariadb-10.0.16-win32 ...

  4. JTable

    final Table table = new Table(parent, SWT.NONE | SWT.FULL_SELECTION); final GridData gd = new GridDa ...

  5. 不安装rpm包,取出rpm包里的文件

    1.查看rpm包里的文件 [root@VM_166_132 ~]# rpm -qlp mysql5.6.29-1-3.x86_64.rpm |more/etc/ld.so.conf.d/mysql-5 ...

  6. Python数据预处理—训练集和测试集数据划分

    使用sklearn中的函数可以很方便的将数据划分为trainset 和 testset 该函数为sklearn.cross_validation.train_test_split,用法如下: > ...

  7. ACM网络镜像赛

    参加了东大,南理的网络镜像赛,分别答对了两道题和三道题.感觉自己完全被虐了.发现了很多自己应该去掌握的知识,找到了自己的差距.容斥原理,博弈论,等等,这将是我努力的方向. 在跟大神同学和学姐交流的过程 ...

  8. 父子页面(iframe)相互获取对方dom元素

    现在iframe的使用虽然开始越来越少,但是还是有牵涉到iframe的使用情况,特别是多个iframe互相嵌套,又要进行获取的情况. 现在整理了父子iframe之间互相获取的方式. (1)父页面获取子 ...

  9. lucene Filter过滤器

    摘自:http://iamyida.iteye.com/blog/2199368 1.TermFilter:就是按照Term去过滤,跟TermQuery类似: Filter filter = new ...

  10. jquery事件绑定

    window.onload 和 Jquery $(document).ready() 区别 * .用JavaScript的方式window.onload :必须等页面上所有的元素(css/js/图片) ...