DFS or BFS
文章平均质量分 83
risker_2013
这个作者很懒,什么都没留下…
展开
-
UVA 216 Getting in Line
题意就是求将n个点所连接起来的最短距离,每两个点之间的距离还需要加16。我用的是暴力(全排列),可以用回溯法,但是回溯法我现在还没学会,等我学会了再写一遍。据说效率更高些~123456789101112131415161718192021222324252627282930313233343原创 2013-08-03 14:44:09 · 761 阅读 · 0 评论 -
Codeforces Round #134 (Div. 2) C. Ice Skating
C. Ice Skatingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBajtek is learning to skate on ice. He's a b原创 2014-03-21 17:19:13 · 709 阅读 · 0 评论 -
nefu 640 Number Guessing
Number GuessingTime Limit 1000msMemory Limit 65536KdescriptionNumber Guessing is a computer game. First, the computer chooses four different d原创 2014-05-02 18:26:47 · 720 阅读 · 0 评论 -
nefu 627 剪纸游戏(搜索)
剪纸游戏Time Limit 1000msMemory Limit 65536KdescriptionRecently Raven is addicted to paper cutting games. There is a rectangle-shape paper. Its le原创 2014-05-02 18:41:40 · 705 阅读 · 0 评论 -
UVA 20344 23 out of 5(回溯+全排列)
大致题意是:先输入5个数,然后用‘+’,‘-’,‘*’,连接起来,看看是否能恰好等于23,若能,输出“Possible”,否则输出“Impossible”。用回溯+全排列就可以啦~ 23 Out of 5Input: standard inputOutput: standard outputTime Limit: 1 secondMemory Limit: 32 M原创 2013-08-06 11:46:03 · 676 阅读 · 0 评论 -
UVA 167 The Sultan's Successors(八皇后问题变形)
题意:给定一个8*8的棋盘,每个上都有一个固定的数,放置8个皇后,使他们不在同行,同列,主斜线和副斜线上,然后求出最大的权值。思路:一行只能放一个皇后,所以我们一行一行找过去。一共只要找8行。开3个数组。一个代表列,一个代表主斜线。一个代表副斜线。如果一个点放了皇后。就把列,主副斜线进行标记。然后到下一行找下一个皇后。直到找不到进行回溯。。每次找到最后一行。都把权值和和原创 2013-08-06 16:14:17 · 773 阅读 · 0 评论 -
UVA 331 Mapping the Swaps (回溯+dfs)
题意是:求一个数列经最少步骤变为由大到小一共有多少种排法。思路:用冒泡法所需步骤就最少。然后用dfs搜索求出排法数。 Mapping the Swaps Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This原创 2013-08-06 13:39:07 · 601 阅读 · 0 评论 -
UVA 639 Don't Get Rooked
本人乃一搜索初学者,这道题的思路参考大神思路,思路太好,本人太过于激动,由此,发了这一篇。O(∩_∩)O~以下是大神思路: 这是一道类似于N皇后的问题,叫我们将车放到小棋盘上面去,规则也类似,让每个车都不能攻击到其他车,然后有墙阻隔,车是不能攻击到墙后的车的。用回溯法来解决这个问题。定义一个mat数组,先将棋盘的情况读入,如果是 ’ .’就将mat[i][j] 置为原创 2013-08-03 20:29:13 · 647 阅读 · 0 评论 -
UVA 301 Transportation
Transportation Ruratania is just entering capitalism and is establishing new enterprising activities in many fields including transport. The transportation company TransRuratania is starti原创 2013-08-04 15:44:04 · 678 阅读 · 0 评论 -
UVA 539 The Settlers of Catan(回溯法)
The Settlers of Catan Within Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted wilde原创 2013-08-04 11:29:36 · 570 阅读 · 0 评论 -
Codeforces Round #150 (Div. 2) B. Undoubtedly Lucky Numbers
点击打开题目链接B. Undoubtedly Lucky Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp原创 2014-04-18 13:10:35 · 1354 阅读 · 0 评论