A - The Snail 很简单的一个蜗牛爬墙的问题,递归就可以解决。当然要先看懂英文题目啦。DescriptionA snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can cl...
继续阅读 »
G - Oil Deposits 连通块问题,和《算法竞赛入门经典(第二版)》里面的油田问题是一样的,利用dfs提高效率,递归一下就好了。DescriptionThe GeoSurvComp geologic survey company is responsible for detecting...
继续阅读 »
E - Rails Rails,火车问题,栈的典型应用,通过入栈来对比是否成立,《算法竞赛入门经典(第2版)》里面的例子,不多做解释。The local tradition is that every train arriving from the direction A continues i...
继续阅读 »
D - Find a way Find a way这题目要多坑有多坑,竟然会有KFC四周全是墙的这种测试数据,你家开个KFC旁边全都建个墙围起来?好吧,吐槽完毕,说下解题思路,一开始我是从每个KFC向Y、M使用BFS来找最短路径,把每个KFC到他们两个人的最短路径放到列队里面去,最后front(...
继续阅读 »
C - Dungeon Master 三维迷宫而已啦,其实题目没怎么看,就觉得是三维迷宫,然后根据二维迷宫的思路,注意一下三维空间坐标的处理就AC啦。DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The du...
继续阅读 »
B - Catch That Cow 抓牛问题,一开始使用了回溯法递归,然后就Time Limit Exceeded了,于是乎,用上了队列,然后上bfs,左边搜,右搜,两倍传送再搜一波,瞬间秒杀,妈妈再也不用担心我会超时,哈哈哈哈....DescriptionFarmer John has been informed of the locat...
继续阅读 »