HDU - 5444 Elven Postman (根节点到指定节点的路径)

这篇博客讲述了精灵世界中的一种特殊邮递方式,尽管有魔法传送,但有时他们仍使用传统方式递送邮件。精灵住在类似二叉树的树上,房间编号从东到西。邮差需要根据根节点上的序列来确定如何将邮件送到指定房间。问题转化为从根节点到目标节点的路径。给定树的节点数和根节点序列,以及需要递送的邮件数量和目标房间,需要输出邮差的移动方向(E或W)。解决方案包括建立二叉树并记录路径。
摘要由CSDN通过智能技术生成

Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not something to be taken lightly. Also, they live on trees. However, there is something about them you may not know. Although delivering stuffs through magical teleportation is extremely convenient (much like emails). They still sometimes prefer other more “traditional” methods. 

So, as a elven postman, it is crucial to understand how to deliver the mail to the correct room of the tree. The elven tree always branches into no more than two paths upon intersection, either in the east direction or the west. It coincidentally looks awfully like a binary tree we human computer scientist know. Not only that, when numbering the rooms, they always number the room number from the east-most position to the west. For rooms in the east are usually more preferable and more expensive due to they having the privilege to see the sunrise, which matters a lot in elven cultu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值