DFS
文章平均质量分 72
mrcoderrev
C
展开
-
N皇后问题 hdu2553
#include #include using namespace std;#define N 20int dp[N], a[N][N];int n, tmp;void dfs(int k);int judge(int x,int y);int main(){ memset(a,0,sizeof(a)); for(n=1;n原创 2016-05-14 17:04:47 · 352 阅读 · 0 评论 -
UVA - 11181 Probability|Given (dfs处理条件概率)
Probability|Given UVA - 11181 #include #include using namespace std;const int N = 500;const int inf = 0x3f3f3f3f;const int maxn=1e6+2;typedef long long LL;double p[N], vis[N], ans, a[原创 2017-05-04 12:09:25 · 155 阅读 · 0 评论 -
uva Biggest Number UVA - 11882 || nbut [1464] Biggest Number(dfs强力剪枝)
Biggest Number UVA - 11882 数据较弱题目大意:有一个R*C的矩阵,矩阵里面有1~9的数字(太好了不用处理前导0),或者是#(代表不能通过),先要从矩阵任意一点出发(之前英语抓鸡看成了边界,英语差的孩纸伤不起啊>_思路:DP?记忆化搜索?30个点噢,时间吃得消内存都吃不消啦。所以呢?搜索。还是超时啊?剪枝啊。剪枝1:假设当前答案为ans,那么原创 2017-05-02 12:03:30 · 176 阅读 · 0 评论 -
cf 723D Lakes in Berland(dfs)
D. Lakes in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe map of Berland is a rectangle of th原创 2017-11-08 11:54:20 · 88 阅读 · 0 评论 -
SPOJ MBEEWALK Bee Walk(记忆化搜索+直角坐标系转化为斜坐标系)
EnglishVietnameseA bee larva living in a hexagonal cell of a large honey comb decides to creep for a walk. In each “step” the larva may move into any of the six adjacent cellsand after n转载 2017-04-10 11:15:55 · 1835 阅读 · 0 评论 -
poj 1191 棋盘分割 (dfs)
棋盘分割Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 14917 Accepted: 5331Description将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同原创 2017-11-01 20:29:48 · 168 阅读 · 0 评论 -
poj 3083 Children of the Candy Corn (dfs+bfs)
The cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their que原创 2017-11-01 20:29:58 · 183 阅读 · 0 评论 -
poj 1054The Troublesome Frog(几何——>dfs+剪枝)
In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a well-deserved reputation, because the frogs jump through your rice paddy at night, flattening rice plants. In the原创 2017-03-26 10:49:56 · 175 阅读 · 0 评论 -
poj 3411 Paid Roads(dfs+标记路径->求最少花费)
Paid RoadsTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionA network of m roads connects N cities (numbered from 1 to N). There m原创 2017-11-14 17:52:32 · 291 阅读 · 0 评论 -
cf 727A Transformation: from A to B(搜索)
A. Transformation: from A to Btime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasily has a number a, which原创 2017-11-14 17:53:37 · 778 阅读 · 0 评论 -
hdu 6265 Master of Phi(公式推导)
这题就是个公式化简,急中生智用搜索去优化时间复杂度 比赛时 我一看是数学题 因为自己数学功底差就交给队友去做,,最后他也没做出来 。。。打铁这个锅应该我背,没有去帮队友一起想 也许最后还能想到dfs。。。 只顾着自己想题 个人意识太强,没有团体意识。。。毫无大局观念,特在此反思自己的过错 希望以后能够将自己的眼光格局放大一点#include <cstdio>#i...原创 2018-05-14 19:43:37 · 812 阅读 · 0 评论 -
leetcode 95. Unique Binary Search Trees II
Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n.Example:Input: 3Output:[[1,null,3,2],[3,2,null,1],[3,1,null,null,2],[2,1,3],[1,null,2,...原创 2019-03-03 11:35:30 · 162 阅读 · 0 评论 -
poj 1062 昂贵的聘礼 (dfs||最短路)
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,原创 2017-03-28 10:46:13 · 151 阅读 · 0 评论 -
hdu 5952 Counting Cliques(dfs 优化)
Counting CliquesTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2660 Accepted Submission(s): 972Problem DescriptionA clique i原创 2017-10-08 01:09:51 · 278 阅读 · 0 评论 -
codeforces.contest/835/problem/D Palindromic characteristics (记忆化搜索)
Palindromic characteristicstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPalindromic characteristics of原创 2017-08-02 10:40:58 · 243 阅读 · 0 评论 -
pat L3-003. 社交集群
L3-003. 社交集群时间限制 1000 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 陈越在社交网络平台注册时,用户通常会输入自己的兴趣爱好,以便找到和自己兴趣相投的朋友。有部分兴趣相同的人们就形成了“社交集群”。现请你编写程序,找出所有的集群。原创 2016-05-16 16:27:18 · 1319 阅读 · 0 评论 -
zoj 3944
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit Status Practice ZOJ 3944DescriptionIn a BG (dinner gathering) for ZJU ICPC team, the coaches wanted t原创 2016-05-30 11:39:38 · 326 阅读 · 0 评论 -
L2-016. 愿天下有情人都是失散多年的兄妹(dfs)@
L2-016. 愿天下有情人都是失散多年的兄妹时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越呵呵。大家都知道五服以内不得通婚,即两个人最近的共同祖先如果在五代以内(即本人、父母、祖父母、曾祖父母、高原创 2016-07-20 00:04:32 · 1704 阅读 · 0 评论 -
L2-007. 家庭房产 (并查集||无向图)
L2-007. 家庭房产时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。输入格式:输入第一行原创 2017-03-28 11:44:50 · 236 阅读 · 0 评论 -
poj 2488 A Knight's Journey (dfs)
Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two squares in原创 2017-03-13 12:10:07 · 194 阅读 · 0 评论 -
hiho #1474 : 拆字游戏(dfs)@
#1474 : 拆字游戏时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Kui喜欢把别人的名字拆开来,比如“螺”就可以拆成“虫田糸”,小Kui的语文学的不是很好,于是她决定使用编程的方式来解决这个问题。给出一个01矩阵,1占据的部分即为需要拆的字,如果两个1分享一条边,那么它们连通。连通具有传递性,即如果a、b原创 2017-03-13 12:11:02 · 374 阅读 · 0 评论 -
51 nod 1400 序列分解(dfs+剪枝)@
1400 序列分解基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注小刀和大刀是双胞胎兄弟。今天他们玩一个有意思的游戏。 大刀给小刀准备了一个长度为n的整数序列。小刀试着把这个序列分解成两个长度为n/2的子序列。这两个子序列必须满足以下两个条件:1.他们不能相互重叠。原创 2017-03-13 12:11:37 · 267 阅读 · 0 评论 -
EOJ 3260 袋鼠妈妈找孩子(dfs路径查找(过程优化))
袋鼠妈妈找孩子Time limit per test: 1.5 secondsTime limit all tests: 10.0 secondsMemory limit: 256 megabytes袋鼠妈妈找不到她的孩子了。她的孩子被怪兽抓走了。袋鼠妈妈现在在地图的左上角,她的孩子在地图第 x 行第 y 列的位置。怪兽想和袋鼠妈妈玩一个游戏:他不想让袋鼠妈原创 2017-05-15 11:09:21 · 450 阅读 · 0 评论 -
uva 10795 A Different Task (汉诺塔升级)
I - A Different Task 汉诺塔结论,把一个柱子上的所有盘子移到另一个柱子上需要2^(n)-1步#include#include#include#include#include#include#include#include#includeusing namespace std;const int N = 1100000;t原创 2017-07-21 22:08:06 · 259 阅读 · 0 评论 -
hdu RXD and dividing(dfs)
RXD and dividingTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 230 Accepted Submission(s): 95Problem DescriptionRXD has a原创 2017-08-01 19:13:08 · 335 阅读 · 0 评论 -
zzuli 2525: 咕咕的搜索序列(dfs合法序列)
2525: 咕咕的搜索序列时间限制: 1 Sec 内存限制: 128 MB提交: 371 解决: 40[提交] [状态] [讨论版] [命题人:外部导入]题目描述咕咕已经学到树上的深度优先搜索 (dfs) 啦!由于同一棵树不同的 dfs 访问结点的次序不一样,咕咕干脆定义 了一个搜索序列:一开始序列为空,而每次离开这个点,并且不会再返回这个点时,就把这个点加入序列中, 最后返回到根节...原创 2019-04-23 16:01:04 · 534 阅读 · 0 评论