随笔分类 -  BFS(广度优先搜索)

摘要:Fire Game Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this bo 阅读全文
posted @ 2019-02-24 17:20 suvvm 阅读(335) 评论(0) 推荐(0)
摘要:水陆距离 描述 给定一个N x M的01矩阵,其中1表示陆地,0表示水域。对于每一个位置,求出它距离最近的水域的距离是多少。 矩阵中每个位置与它上下左右相邻的格子距离为1。 输入 第一行包含两个整数,N和M。 以下N行每行M个0或者1,代表地图。 数据保证至少有1块水域。 对于30%的数据,1 <= 阅读全文
posted @ 2019-01-28 20:00 suvvm 阅读(676) 评论(0) 推荐(0)
摘要:Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you ar 阅读全文
posted @ 2019-01-08 21:01 suvvm 阅读(373) 评论(0) 推荐(0)
摘要:非常可乐 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101 阅读全文
posted @ 2018-12-07 14:57 suvvm 阅读(405) 评论(0) 推荐(1)
摘要:Dungeon Master You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be fi 阅读全文
posted @ 2018-12-06 20:11 suvvm 阅读(319) 评论(0) 推荐(1)
摘要:Nightmare Ⅱ Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were trapped in a big maze separately. More te 阅读全文
posted @ 2018-12-05 20:00 suvvm 阅读(367) 评论(0) 推荐(0)