P177 test 6-4 UVa439
//P177 test 6-4 UVa439 #include<cstdio> #include<cstring> #include<queue> using namespace std; , , , , -, -, -, -}; //转向控制 , -, , -, , -, , -}; ][]; //记录步数 void bfs(int x,int y,int ex,int ey) { queue<int> a, b; a.push(x); b.push(y); int px, py; ; while(!a.empty()) { px = a.front(); a.pop(); py = b.front(); b.pop(); ; i < ; i++) { && px + turnx[i] <= && py + turny[i] > && py + turny[i] <= ) { step[px + turnx[i]][py + turny[i]] = step[px][py] + ; b.push(py + turny[i]); a.push(px + turnx[i]); if(px + turnx[i] == ex && py + turny[i] == ey) { kase = ; break; } } } if(kase)break; } } int main() { int x, ex, y, ey; ],s2[]; ) { x = s1[] - ; y = s1[] - ' ; ex = s2[] - ; ey = s2[] - ' ; memset(step, , sizeof(step)); bfs(x,y,ex,ey); printf("%d\n", step[ex][ey]); } ; }
P177 test 6-4 UVa439的更多相关文章
- P177 test 6-3 UVa536
//P177 test 6-3 #include<cstdio> #include<cstring> using namespace std; +],s2[+]; int re ...
- [刷题]算法竞赛入门经典(第2版) 6-4/UVa439 6-5/UVa1600
比较忙比较累,只贴代码了. 题目:6-4 UVa439 - Knight Moves //UVa439 - Knight Moves //Accepted 0.000s //#define _XIEN ...
- uva-439
题意:骑士在一个8*8的棋盘上移动,1-8代表行号,a-h代表列号,给出骑士的初始位置和目的位置,求骑士最少的移动步数:题目隐含一层意思(骑士移动规则是中国象棋的“马”的走法) 输入:一串字符串,包含 ...
- uva439 - Knight Moves(BFS求最短路)
题意:8*8国际象棋棋盘,求马从起点到终点的最少步数. 编写时犯的错误:1.结构体内没构造.2.bfs函数里返回条件误写成起点.3.主函数里取行标时未注意书中的图. #include<iostr ...
- UVa439——骑士的移动
简单bfs #include <iostream> #include <cstring> #include <string> #include <map> ...
- Uva439:BFS题目总结
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstring> #include <cstd ...
- UVA439 knightMoves (A*启发搜索)
第一个A*,纪念下. A*要保证最短路一定要估价函数小于等于实际值,越接近越好 估价函数取Manhattan距离除以二. //Rey #include<cstdio> #include&l ...
- 【习题 6-4 UVA-439】Knight Moves
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] bfs模板题 [代码] /* 1.Shoud it use long long ? 2.Have you ever test sev ...
- UVA439 骑士的移动 Knight Moves
#include<bits/stdc++.h> using namespace std; char a,c; int b,d; ][]; ]={,,,-,,-,-,-}; ]={,-,,, ...
随机推荐
- Struts2验证
一.声明式验证 1.字段验证 fielderror的两种显示方式 fielderror的提示信息可以国际化 2.非字段验证:actionErrors / <s:actionerror> 例 ...
- 使用Linux自定义自动补全命令完善自己的shell脚本
对于Linuxer来说,自动补全是再熟悉不过的一个功能了.当你在命令行敲下部分的命令时,肯定会本能地按下Tab键补全完整的命令,当然除了命令补全之外,还有文件名补全. Bash-completion ...
- PHP新手之学习类与对象(1)
本文介绍的是PHP程序设计语言中类和对象的基本知识,适合初学者阅读,希望对你有帮助,一起来看. PHP 5 引入了新的对象模型(Object Model).完全重写了 PHP 处理对象的方式,允许更佳 ...
- redhat5安装phantomjs
Linux 64-bit Download phantomjs-2.1.1-linux-x86_64.tar.bz2 (22.3 MB) and extract the content. Note: ...
- OGG数据仓库以及单向复制(二)
Configure Extract(提取) Process in Source system 配置capture(捕获)参数 Edit extract process parameter G ...
- FlashPlayer11 异步解码 Bitmap
Flash Player 11引入了一个全新的功能是异步解码位图的功能,这个功能对某些类型的Flash应用会很有效,尤其是需要加载大分辨率的位图的相册或游戏会有显著效果,使用位图图像时,可以异步解码和 ...
- eclipse jsp html 格式化 format
eclipse jsp html 格式化 format http://blog.csdn.net/hexin373/article/details/7677250
- [随笔]利用云虚拟机和学校VPN实现校外访问校内站点(反向代理)
探究背景简介: 大学校内站点一般不对外开放,个人认为原因有二: 一是站点内容受众就是大学师生: 二是站点基本无防御措施,在公网环境下容易发生意外情况. 至于为何不对外开放,不是这篇随笔探讨的重点,利用 ...
- java gc的调用机制 和编程规则
转载:http://sunzhyng.iteye.com/blog/480148 一个优秀的Java程序员必须了解GC的工作原理.如何优化GC的性能.如何与GC进行有限的交互,有一些应用程序对性能要求 ...
- removeEventListener('2016');
2016----最后一天工作日要快结束了,趁剩下的一点时间写篇博客玩玩,想到啥就写啥.总结下来就一句---累并快乐着... 先祝大家新年快乐!万事如意发大财. 一年跳了三家公司,上半年在家小公司干着整 ...