#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
struct node
{
int x;
int y;
int s;
};
int g[][];
int d[][]={{,},{-,},{,},{,-}};
int main()
{
// freopen("in.in","r",stdin);
node s, t;
string l;
queue<node>q;
vector<node>v; for(int i = ; i <= ; i++)
for(int j = ; j <= ; j++)
g[i][j] = ; for(int i = ; i <= ; i++)
for(int j = ; j <= ; j++)
scanf("%d",&g[i][j]); s.x = ;
s.y = ;
s.s = -;
q.push(s);
while(q.size())
{
s = q.front();
q.pop();
g[s.x][s.y] = s.s;
if(s.x == && s.y == ) break; for(int i = ; i < ; i++)
{
t.x = s.x + d[i][];
t.y = s.y + d[i][];
t.s = s.s - ;
if(g[t.x][t.y] == )
q.push(t); }
}
while(q.size()) q.pop();
s.x = ;
s.y = ;
q.push(s);
while(q.size())
{
s = q.front();
q.pop();
if(s.x == && s.y == ) break;
for(int i = ; i < ; i++)
{
t.x = s.x + d[i][];
t.y = s.y + d[i][];
if(g[t.x][t.y] == g[s.x][s.y] + )
{
q.push(t);
v.push_back(t);
break;
}
}
}
for(int i = v.size() - ; i >= ; i--)
printf("(%d, %d)\n",v[i].x-,v[i].y-);
printf("(4, 4)\n");
return ;
}

[kuangbin带你飞]专题一 简单搜索 - K - 迷宫问题的更多相关文章

  1. [kuangbin带你飞]专题一 简单搜索 题解报告

    又重头开始刷kuangbin,有些题用了和以前不一样的思路解决.全部题解如下 点击每道题的标题即可跳转至VJ题目页面. A-棋盘问题 棋子不能摆在相同行和相同列,所以我们可以依此枚举每一行,然后标记每 ...

  2. [kuangbin带你飞]专题一 简单搜索(回顾)

    A - 棋盘问题 POJ - 1321 注意条件:不能每放一个棋子,就标记一行和一列,我们直接枚举每一行就可以了. AC代码: #include<iostream> #include< ...

  3. [kuangbin带你飞]专题一 简单搜索 - E - Find The Multiple

    //Memory Time //2236K 32MS #include<iostream> using namespace std; ]; //保存每次mod n的余数 //由于198的余 ...

  4. [kuangbin带你飞]专题一 简单搜索 棋盘问题

    题来:链接https://vjudge.net/problem/OpenJ_Bailian-132 J - 棋盘问题 1.题目: 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别. ...

  5. [kuangbin带你飞]专题一 简单搜索

            ID Origin Title 454 / 1008 Problem A POJ 1321 棋盘问题   328 / 854 Problem B POJ 2251 Dungeon Ma ...

  6. [kuangbin带你飞]专题一 简单搜索 回顾总结

    第二题:bfs,忘了将queue清空. 第三题:bfs,记得使用vis数组,防止重复入队

  7. 迷宫问题 POJ - 3984 [kuangbin带你飞]专题一 简单搜索

    定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, ...

  8. [kuangbin带你飞]专题一 简单搜索 Find a way HDU - 2612

    Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year ...

  9. Catch That Cow POJ - 3278 [kuangbin带你飞]专题一 简单搜索

    Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. ...

随机推荐

  1. Linux特殊权限设置以及使用

    Linux文件权限特殊权限(s-s-t) 什么是suid权限 SUID是可执行文件的特殊文件权限,使其他用户能够以文件所有者的有效权限运行文件. 代替执行权限的正常x代替用户的s(指示SUID )特权 ...

  2. NX二次开发-Ufun API Example

    UF公共类型 UF_begin_timer计时函数 https://www.cnblogs.com/nxopen2018/p/10957135.html UF_end_timer计时函数 https: ...

  3. readUTF()和writeUTF()

    readUTF()和writeUTF() 这是dataOutputStream 的方法~~使用utf-8编码 其实就是从unicode变过来的,utf8编码把unicode的ASCII编码变成1个字节 ...

  4. TCP/IP报文格式

    1.TCP首部格式 1.1 格式各字段含义 源端口号( 16 位):它(连同源主机 IP 地址)标识源主机的一个应用进程. 目的端口号( 16 位):它(连同目的主机 IP 地址)标识目的主机的一个应 ...

  5. winform界面设计

    http://www.cnblogs.com/wuhuacong/  这位大师给了我指导方向 http://officeribbon.codeplex.com 提供了ribbon界面的控件 动态web ...

  6. require.js实现单页web应用(SPA)

    本文转载自:https://blog.csdn.net/qq_33401924/article/details/53815922 移动端单页应用基本上是做移动端最流行的的方式了,但是对于很多前端来说, ...

  7. cdh5.47 上配置flume

    flume 配置文件 # Define a memory channel called ch1 on agent1agent1.channels.ch1.type = memoryagent1.cha ...

  8. 【HDUOJ】1257 最少拦截系统

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1257 题意:经典题. 题解:最长上升子序列. 代码: #include <iostream> ...

  9. 10种JavaScript特效实例让你的网站更吸引人

    我们有三种主要的方法(从难到易):自己动手写脚本;使用类似于jQuery和mooTools的JavaScript框架(可以让编写代码变得更容易些);使用能工作于现有的JavaScript框架下的提前预 ...

  10. Mongodb安装遇到的问题

    今天我第一次接触MongoDB,在安装过程中,因为对这个东西不了解,报错了我也不知道是哪里的错,还在网上查了半天资料,后来我懂了,感觉上午就是在浪费时间,是我没睡醒,没睡醒.. 在安装上MongoDB ...