![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS
文章平均质量分 82
_OTTFF
这个作者很懒,什么都没留下…
展开
-
HDU_1501_Zipper
Zipper这个名字很形象……s1 s2两个序列不改变顺序交替构成s3dfs的题目因为深度是固定的,而找到结果就可以弹出。不过我用bfs居然过了……以下为bfs。#include #include #include #include using namespace std;const int M=205;char s1[M],s2[M],s3[2*M];int原创 2015-07-25 17:03:41 · 366 阅读 · 0 评论 -
CSU_1508_地图的四着色
地图的四着色Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 66 Solved: 35[Submit][Status][Web Board]Description有一个R行C列的网格地图,每个国家是一个四连通区域。你的任务是用红,绿,蓝,黄四种颜色给地图着色,使得相邻国家的颜色不同。一个人着色比较无趣,所以你原创 2015-08-24 17:03:30 · 1100 阅读 · 0 评论 -
UVA_10651_PebbleSolitaire
10651 - Pebble SolitaireTime limit: 3.000 secondsPebble solitaire is an interesting game. This is a game where you are given a board with an arrangementof small cavities, initially all but one原创 2015-08-17 15:02:59 · 303 阅读 · 0 评论 -
HDU_1010_TempterOfTheBone
魔鬼骨头……迷宫问题这个题目因为其中一个return查了好久,而恰恰思路正确测试数据可以过……&这个题目需要剪枝,因为实在减掉了太多。题目中说t时刻门会开,这并不是一个bfs的问题,而是dfs因为bfs只会求出最短的时间剪枝101010010101101010010101如上从1的位置出发经过奇数时间必定达到0原创 2015-07-25 17:20:48 · 285 阅读 · 0 评论 -
POJ_2676_Sudoku
数独,当年一家人都很疯狂的玩如今用电脑dfs非常容易的就解决了。判断在同一大格里可以填有点麻烦。题目每组输入其实是9个整数,所以……另外就是题目要求对于有多个解的题目,输出一个可行解。#include #include using namespace std;int ss[9]; //输入这里也卡了一下int s[9][9];原创 2015-07-23 18:36:23 · 330 阅读 · 0 评论 -
ZOJ_1008_GnomeTetravex
这个问题在输出上坑了一下人。题目中Print a blank line between each game case.between……总体感觉没什么特别的,据说不剪枝会超时。剪枝做的就是把相同的卡片 拿出来。#include #include using namespace std;const int M=6;int s[M*M][5]; //记录输入原创 2015-07-24 09:43:17 · 410 阅读 · 0 评论 -
ZOJ_1204_AdditiveEquations
第一个dfs的题目就是求一个没有重复的正整数的序列能组成的加法算式并输出一边是几个加数,另一边是和。排列顺序每个式子数字由小到大加数个数由少到多(这个还坑了我一下)#include #include #include using namespace std;const int M=31;int s[M]; //存储输入int l[M];原创 2015-07-23 15:39:24 · 1386 阅读 · 0 评论 -
HDU_2553_N皇后问题
经典问题。但是方案却不唯一,记得很早的时候写过n个循环嵌套的版本。现在想想蠢死了。只有八皇后是否在同一直线斜线上判断方法也有多种。首先一行一行(或者一列一列)填皇后这个应该是没的说的。判断斜线是个要点法1就是打一个棋盘然后每填上一个皇后就把皇后的攻击范围全部标记。回溯的时候再把皇后的攻击范围全部改回去。 判断皇后能不能在那个格子很快。但是这个填改的过程应该原创 2015-07-23 17:03:42 · 373 阅读 · 0 评论 -
HDU_1198_FarmIrrigation
Farm IrrigationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7285 Accepted Submission(s): 3123Problem DescriptionBenny has原创 2015-08-11 16:02:42 · 504 阅读 · 0 评论 -
CF_448E_Divisors
Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBizon the Champion isn't just friendly, he also is a rigorous原创 2015-07-29 22:32:28 · 472 阅读 · 0 评论 -
CF_288B_PoloThePenguinAndHouses
Polo the Penguin and Houses time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle penguin Polo loves his home villa原创 2015-07-29 22:22:12 · 432 阅读 · 0 评论 -
POJ_1426_FindTheMultiple
Find The MultipleTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 21478 Accepted: 8797 Special JudgeDescriptionGiven a positive integer n, write a pr原创 2015-07-29 08:44:26 · 332 阅读 · 0 评论 -
POJ_2362_Square
SquareTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 21782 Accepted: 7606DescriptionGiven a set of sticks of various lengths, is it possible to join th原创 2015-07-29 08:57:51 · 302 阅读 · 0 评论 -
UVA_10911_FormingQuizTeams
10911 - Forming Quiz TeamsTime limit: 3.000 secondsYou have been given the job of forming the quiz teams for the next `MCA CPCI Quiz Championship'.There are 2 N students interested to participat原创 2015-08-09 23:40:43 · 414 阅读 · 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原创 2015-08-09 23:22:13 · 999 阅读 · 0 评论 -
CSU_1660_K-Cycle
1660: K-CycleTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 124 Solved: 31[Submit][Status][Web Board]DescriptionA simple cycle is a closed simple path, with no other repeated vertic原创 2015-08-09 17:34:49 · 508 阅读 · 0 评论 -
ZOJ_1004_AnagramsByStack
Anagrams by StackTime Limit: 2 Seconds Memory Limit: 65536 KBHow can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TRO原创 2015-08-09 17:39:05 · 741 阅读 · 0 评论 -
CF_540C_IceCave
这个题目本身从任务的角度是一个dfs的题目。因为只需要判断能否最后到达指定位置。与一般的迷宫不同的一点事这个的最后到达的位置要求为‘X’而不能是‘.’如果是‘.’则要再到达一次。这个问题本事判定并不复杂。问题在于这个问题给出的迷宫很大500*500在写dfs时应该注意判过的点在回溯时并不需要改回‘.’因为回退前的路径都是错误的(正确就弹出了),不需要再从别的路径到达再判原创 2015-07-26 17:13:44 · 598 阅读 · 0 评论 -
HDU_3335_Divisibility(DancingLinksX重复覆盖||dfs||暴力)
题意给一个数组让从中选出尽可能多的数字,他们之间两两不存在整除关系这题目貌似正经做法应该是最小路径覆盖但是这题DancingLinksX甚至DFS甚至直接for循环暴力都可以过……原创 2016-05-02 20:26:36 · 795 阅读 · 0 评论