搜索
Frontier_Setter
这个作者很懒,什么都没留下…
展开
-
USACO 6.3.1 Fence Rails 01多背包问题(BS+IDDFS)
http://train.usaco.org/usacoprob2?a=NaWWtjt80VA&S=fence8题目大意:有N(1-50)块原木,要切成R(1-1023)块长度(1-128)可重复的木板,并不一定所有的木板都能被切出来,求能够交货的最大木板数量错误想法:我一开始正着想觉得有种网络流的感觉,把每个原木看作一个有限容量的节点,和每个木板结点以无限容量的管道连接,木板结点在和汇点...原创 2018-02-12 21:12:32 · 601 阅读 · 0 评论 -
[LeetCode] (medium) 416. Partition Equal Subset Sum
https://leetcode.com/problems/partition-equal-subset-sum/Given anon-emptyarray containingonly positive integers, find if the array can be partitioned into two subsets such that the sum of elemen...原创 2019-04-30 12:27:24 · 241 阅读 · 0 评论 -
[LeetCode] (medium) 240. Search a 2D Matrix II
https://leetcode.com/problems/search-a-2d-matrix-ii/Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are so...原创 2019-02-17 22:16:00 · 224 阅读 · 0 评论 -
[LeetCode] (medium) 34. Find First and Last Position of Element in Sorted Array
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/Given an array of integers nums sorted in ascending order, find the starting and ending position of a given tar...原创 2019-02-04 22:07:06 · 86 阅读 · 0 评论 -
[LeetCode] (medium) 33. Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5...原创 2019-02-04 21:47:33 · 620 阅读 · 0 评论 -
[LeetCode] (medium) 127. Word Ladder
https://leetcode.com/problems/word-ladder/Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such ...原创 2019-02-14 21:39:50 · 164 阅读 · 0 评论 -
USACO 6.5.5 Checker Challenge 回溯
http://train.usaco.org/usacoprob2?a=BI4LEPNXcEa&S=checker题目大意:在一个N*N的棋盘上放棋子,要求每一行每一列都有一个,每一个对角线不超过一个(不仅仅主对角线),要求输出前三个答案(每一行的棋子所在的列号)以及摆放方法总数USACO最后一题,再加上题目里宣扬的种种紧张氛围,还给了整整五个提示,我还以为会是一道巨坑,没想到就是简单的回...原创 2018-02-17 00:42:48 · 313 阅读 · 0 评论 -
USACO 6.5.4 The Clocks BFS
http://train.usaco.org/usacoprob2?a=BI4LEPNXcEa&S=clocks题目大意:给九个钟的初始状态,指针只可能指向3,6,9,12,有九种操作,每种操作拨动一个固定组合的种顺时针45°,求最少操作能够把所有钟拨到12的情况(操作数相同时,要操作的数字小),按顺序输出一开始觉得每次有九种选择的可能性,又要输出操作数最少的情况,就想到了用IDDFS,但...原创 2018-02-17 00:09:28 · 307 阅读 · 0 评论 -
USACO 6.5.3 Betsy's Tour 搜索剪枝
http://train.usaco.org/usacoprob2?a=BI4LEPNXcEa&S=betsy题目大意:一个N*N的方阵(N<=7),求从左上角出发到左下角结束经过每个格子一次且仅一次的路径总数听说标准的做法是在左侧补两列然后作为等效的哈密顿回路用插头dp的方法求解,但是我实在是看不懂,所以我学了搜索剪枝的方法,没想到过的绰绰有余,搜索真是其乐无穷啊参考资料:http...原创 2018-02-16 20:11:41 · 349 阅读 · 0 评论 -
USACO 6.4.1 The Primes 搜索剪枝
http://train.usaco.org/usacoprob2?a=gY0nBCREMEt&S=prime3题目大意:往一个5*5的方阵填数字,最左上角数字给定,要求每一行每一列两个对角线(都是从左到右看)是一个五位素数,且的五位上的数字之和确定(给定)一道令人绝望的搜索题,尝试了四个版本终于过了虽然搜索题给人的感觉往往是麻烦又没什么意义,但这道题(也确实如此)让我第一次接触到了搜索树...原创 2018-02-14 23:00:39 · 281 阅读 · 0 评论 -
USACO 6.3.2 Cryptcowgraphy 剪枝
http://train.usaco.org/usacoprob2?a=Bc6YOT0fW9R&S=cryptcow题目大意:字符串解码,字符串中分布有(C,O,W),每一步交换C-O, O-W中的子串,看能否最后达到目标字符串,如可以输出步数(目标字符串给出,且不含C,O,W)字符串处理+搜索剪枝①最直观的剪枝就是当前字符串中不含COW的前后缀必须要和目标串匹配,但仅仅如此肯定是过不了的...原创 2018-02-13 18:02:54 · 242 阅读 · 0 评论 -
[LeetCode] (medium) 491. Increasing Subsequences
https://leetcode.com/problems/increasing-subsequences/Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increa...原创 2019-05-16 13:03:52 · 81 阅读 · 0 评论