DFS专题1.解数独题意:如下图所示,玩家需要根据9×9盘面上的已知数字,推理出所有剩余空格的数字,并满足每一行、每一列、每一个同色九宫内的数字均含1-9,不重复。数独的答案都是唯一的,所以,多个解也称为无解。本图的数字据说是芬兰数学家花了3个月的时间设计出来的较难的题目。但对会使用计算机编程的你来说,恐怕易如反掌了。本题的要求就是输入数独题目,程序输出数独的唯一解。我们保证所有已知数据的格式都是
转载
2021-04-07 10:33:01
314阅读
2评论
两个剪枝:
1.因为转动过程会出现循环,所以要限制深度
2.因为重复状态没有意义,所以可以记录状态,防止重复搜索
然后模拟+搜索轻松过了
#include
#include
#include
#include
using namespace std;
int a[7] , b[7];
void rotate1 ( )
{
int t1 = a[4] , t2 =
原创
2023-04-24 03:15:16
262阅读
POJ3009 DFS+剪枝 原题: Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16280 Accepted: 6725 DescriptionOn Pla...
转载
2016-03-06 20:19:00
81阅读
2评论
Square Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13374 Accepted Submission(s): 4244 Proble
原创
2021-07-21 15:47:37
104阅读
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could f
转载
2017-07-27 22:47:00
120阅读
George took sticks of the same length and cut them randomly u
原创
2023-04-24 23:33:39
49阅读
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThe doggie found a bone in an ancient maze, wh...
原创
2021-07-14 10:45:25
49阅读
HDU 1501 Zipper 【DFS+剪枝】Problem Description Given three strings, you are to determine whether the third string can be formed by combin...
转载
2018-03-02 10:42:00
64阅读
2评论
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could f
转载
2018-04-10 21:47:00
58阅读
2评论
求最久时间即在无环有向图里求最远路径 dfs+剪枝优化 从0节点(自己添加的)出发,0到1~n个节点之间的距离为1。mt[i]表示从0点到第i个节点眼下所得的最长路径 #include<iostream> #include<cstdio> #include<cstring> #include<str
转载
2017-05-06 14:36:00
75阅读
2评论
Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8353 Accepted Submission(s): 2438 Problem
转载
2016-03-05 16:10:00
54阅读
2评论
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThe doggie found a bone in an ancient maze, wh...
原创
2022-02-06 09:30:47
75阅读
题意: n*m的矩阵 k种颜色 每种颜色有c[i]个 上下左右相邻的格子不能一样的颜色 问你有没有一种染色方法,有的话输出方案。 思路: 暴搜啊,n,m都才5,做完以后大哥的剪枝是奇偶剪枝,其实画完图我就应该想到了。然后自己想了好多,关于奇偶剪枝,自己也就做了HDU1010而已吧。...
转载
2016-09-19 22:26:00
55阅读
http://poj.org/problem?id=1011 题意:若干个相同长度的棍子被剪成若干长度的小棍,求每根棍子原来的可能最小长度。 思路:很经典的搜索题。 我一开始各种超时,这题需要很多剪枝。
转载
2017-01-23 09:21:00
114阅读
2评论
Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 127771 Accepted: 29926 Description George took sticks of the same length and cut the
转载
2016-03-10 08:12:00
89阅读
2评论
http://acm.hdu.edu.cn/showproblem.php?pid=5167
Fibonacci
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3388 Accepted Submis
转载
2018-03-31 09:41:00
47阅读
2评论
给你n*m的格子和K个颜色,然后问你能不能涂出每个格子相邻的颜色都不一样的图案,任意输出一种就好
原创
2021-07-16 15:02:14
145阅读
hdu1010 dfs+路径剪枝
转载
2016-03-26 14:40:00
43阅读
2评论
题意:从S走到D,能不能恰好用T时间。 析:这个题时间是恰好,并不是少于T,所以用DFS来做,然后要剪枝,不然会TEL,我们这样剪枝,假设我们在(x,y),终点是(ex,ey), 那么从(x, y)到(ex, ey),要么时间正好是T-你已经走过的时间,要么要向别的地方先拐一下,以凑出这个正好时间,
转载
2016-08-06 11:12:00
50阅读
Servicing stations A company offers personal computers for sale in N towns (3 对于每个点,无非就是放与不放(注意这里不能单纯根据这个点有没有被覆盖到去判断该不该放服务站)第一个剪枝,如果这个点增加服务站之后,被覆盖得点数没有增加,就可以确定当前点是不放(与放得情况相同干嘛要多加一个点)第二个剪枝,当放得服务站个数大于前面计算的最小值时,剪掉这条路。第三个剪枝,当出现前面有的点无法被覆盖得时候,可以终止这条路得收索。这里问解释一下第三个剪枝得情况,比如当前已经访问到第5个点,而1 这点任然没有被覆盖到,而与1 有联系得
转载
2013-08-06 18:34:00
43阅读