![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
SSimpLe_Y
人一我百,人十我万,然而我做不到。
展开
-
BFS-记录路径
给出三个数A,B,C,A,B代表两个容器,问是否能通过以下几种操作,把A或B里的水变成C。 FILL(i) 把i容器中倒满水,DROP(i) 把i容器中的水倒掉,POUR(i,j) 把i容器中的水倒到j中。 如果能做到,输出需要的最小步数,并输出每一步的操作,如果不能输出impossible。 #include #include #include #include #include原创 2016-06-24 22:20:23 · 566 阅读 · 0 评论 -
SGU 125. Shtirlits(dfs)
There is a checkered field of size N x N cells (1 Ј N Ј 3). Each cell designates the territory of a state (i.e. N2 states). Each state has an army. Let A [i, j] be the number of soldiers in the stat原创 2017-10-10 20:06:03 · 844 阅读 · 0 评论 -
2017 Multi-University Training Contest 3( hdu 6060) RXD and dividing
Problem Description RXD has a tree T, with the size of n. Each edge has a cost. Define f(S) as the the cost of the minimal Steiner Tree of the set S on tree T. he wants to divide 2,3,4,5原创 2017-08-02 10:35:42 · 871 阅读 · 0 评论 -
HDU 1560 DNA sequence(IDA*)
The twenty-first century is a biology-technology developing century. We know that a gene is made of DNA. The nucleotide bases from which DNA is built are A(adenine), C(cytosine), G(guanine), and T(thy原创 2017-05-05 17:39:26 · 759 阅读 · 0 评论 -
lightoj 1009 - Back to Underworld(二分图染色)
The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going t原创 2017-01-14 14:18:23 · 855 阅读 · 0 评论 -
lightoj 1066 - Gathering Food
Winter is approaching! The weather is getting colder and days are becoming shorter. The animals take different measures to adjust themselves during this season. - Some of them "migrate." This means t原创 2016-10-29 09:41:27 · 758 阅读 · 0 评论 -
POJ 1753 Flip Game
Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying原创 2016-08-31 17:12:48 · 674 阅读 · 0 评论 -
BFS-优先队列
第一次做到用优先队列做BFS,第一开始用队列做,发现答案不对,照着网上代码改了半天也还是不对,最后发现别人竟然用的是priority_queue,改了之后答案立马就对了,好神奇,涨了一波姿势。 题目描述: 输入: 第一个数T,T组测试数据。 两个数 n, m; ( 0 接下来n行每行m 个字符。 ‘s’ 表示弟弟目前所在位置。 ‘# ’表示此处为一座山。为了节省体力,不从此处通行。原创 2016-06-15 22:10:42 · 749 阅读 · 0 评论 -
三个水杯-简单bfs
给你三个水杯的容量,只有第一杯里面装满水,其他两个水杯是空的,再输入三个目标值,问你是否能通过倒水达到这个目标,如果能,输入最少步数,如果不能,输出-1. 这题其实就是一个简单的BFS,以前感觉太麻烦了,一直不想写,今天终于AC了它。最后提示一下,BFS还是加上标记比较好。 #include #include #include #include #include using namespac原创 2016-06-12 21:58:05 · 486 阅读 · 0 评论 -
dfs遍历每一个节点
搜索真的是一个很好用的算法,但是一直都是很弱,代码写的也是很弱。 在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来。现在,Tom在第S号城市,他有张该国地图,他想知道如果自己要去参观第T号城市,必须经过的前一个城市是几号城市(假设你不走重复的路)。 #include #include #include #include using namespace s原创 2016-06-12 21:03:36 · 1181 阅读 · 0 评论 -
SGU 134. Centroid(树的重心)
You are given an undirected connected graph, with N vertices and N-1 edges (a tree). You must find the centroid(s) of the tree. In order to define the centroid, some integer value will be assosciate原创 2017-10-13 16:50:01 · 1015 阅读 · 0 评论