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; ][]; ]={,,,-,,-,-,-}; ]={,-,,, ...
随机推荐
- mysql 常用指令
修改表的字符集 88down voteaccepted If you want to change the table default character set and all character ...
- VMVare 桥接上网
桥接模式设置小解: 第1步 虚拟机下fedora安装好后,打开VM虚拟机的菜单栏,单击编辑------虚拟网络编辑器,选择“主机虚拟网络 映射”标签,然后把VMnet0 手动选择为你本地的物理网卡(要 ...
- EntityFrameWork分页
EF分页代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...
- 环信 之 iOS 客户端集成二:配置库
1. 添加依赖库 Build Phases → Link Binary With Libraries MobileCoreServices.framework CFNetwork.framework ...
- 电商网站垮IDC数据备份,MySql主从同步,图片及其它数据文件的同步
原文网址:http://www.bzfshop.net/article/180.html 对一个电子商务网站而言,最宝贵的资源就是数据.服务器是很廉价的东西,即使烧了好几个也问题不大,但是用户数据如果 ...
- mui中文在线手册及教程文档
http://dev.dcloud.net.cn/mui/ui/index.html#mask http://ask.dcloud.net.cn/question/2403 http://ask.dc ...
- jQuery软键盘插件
1.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.or ...
- redhat6 + 11G DG部署
在主库中netca配置 [oracle@HE3dbs]$ cat /u01/app/oracle/product/11gr2/db_1/network/admin/listener.ora #list ...
- #图# #dijkstra# ----- OpenJudge 726:ROADS
OpenJudge 726:ROADS 总时间限制: 1000ms内存限制: 65536kB 描述 N cities named with numbers 1 ... N are connected ...
- xmlns:xsi ——是指xml文件遵守xml规范,xsi全名:xml schema instance
http://blog.sina.com.cn/s/blog_4b6f8d150100nx3e.html http://blog.csdn.net/iaiti/article/details/4226 ...