May 2009 - May 2017 论坛八周年-你的足迹,我的骄傲


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 3109|回复: 3
收起左侧

一个小公司的coding题:波斯王子救公主

[复制链接] |试试Instant~ |关注本帖
天下人 发表于 2015-12-31 11:38:45 | 显示全部楼层 |阅读模式

2015(10-12月) 码农类 硕士 全职@transmarket - 网上海投 - 在线笔试 |Other在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x

后来找了一下,是个多年前就有的旧题。大家有很快编写出来的吗


The Prince of Persia has been thrown onto the top level of Jaffar's
underground labyrinth. The labyrinth consists of h levels strictly on top of
each other. Each level is split into m by n areas. Some areas have columns
that support ceiling, some areas are free. The Prince can move only to free
areas. To move to the level below the Prince can break the floor underneath
him and jump down if there is no column underneath. Every move takes the
Prince 5 seconds. A Princess is waiting for the Prince at the lowest level.
Write a program that will help the Prince to save the Princess as fast as
possible by finding the shortest path between them and outputting time it
took the Prince to find the Princess. The structure of the labyrinth is
. from: 1point3acres.com/bbs given bellow. The Prince’s location is marked with '1', the Princess’s
location is marked with '2'. ‘.’ - marks a free spot and ‘o’ marks a
column.

1 . .-google 1point3acres
o o ..鏈枃鍘熷垱鑷1point3acres璁哄潧
. . .

o o o. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
. . o
. o o
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
o o o. 1point 3acres 璁哄潧
o . .. From 1point 3acres bbs
o . 2. from: 1point3acres.com/bbs

离人笑 发表于 2015-12-31 11:53:31 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
从公主的位置开始 bfs,记录到每个 node 的距离和路径,搜索到王子的位置即可。
回复 支持 反对

使用道具 举报

离人笑 发表于 2015-12-31 11:53:50 | 显示全部楼层
关注一亩三分地微博:
Warald
从公主的位置开始 bfs,记录到每个 node 的距离和路径,搜索到王子的位置即可。
回复 支持 反对

使用道具 举报

离人笑 发表于 2015-12-31 11:54:47 | 显示全部楼层
离人笑 发表于 2015-12-31 11:53
从公主的位置开始 bfs,记录到每个 node 的距离和路径,搜索到王子的位置即可。

信号不好,不好意思发了两遍…
回复 支持 反对

使用道具 举报

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2017-5-24 14:34

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表