dfs
文章平均质量分 79
方品
fangpin.github.io
展开
-
EOJ1981 || POJ1011 经典dfs+剪枝+奇怪的数据
题目:EOJ1981 || POJ1011 经典dfs+剪枝+奇怪的数据 DescriptionGeorge took sticks of the same length and cut them randomly until all partsbecame at most 50 units long. Now he wants to return sticks to th原创 2014-12-18 19:12:18 · 1432 阅读 · 0 评论 -
uva331
//// main.cpp// uva331//// Created by Fangpin on 15/3/11.// Copyright (c) 2015年 FangPin. All rights reserved.//#include #include #include using namespace std;vector a,b;int ans,n;bo原创 2015-03-11 16:16:09 · 774 阅读 · 0 评论 -
uva639 回溯
//// main.cpp// 639//// Created by Fangpin on 15/3/9.// Copyright (c) 2015年 FangPin. All rights reserved.//#include #include #include #include using namespace std;int map[7][7];int a原创 2015-03-09 16:50:48 · 707 阅读 · 0 评论 -
uva 10098 生成字典续序列
生成字典续序列。//// main.cpp// 10098_1//// Created by Fangpin on 15/3/7.// Copyright (c) 2015年 FangPin. All rights reserved.//#include #include #include #include using namespace std;char s原创 2015-03-07 14:36:01 · 822 阅读 · 0 评论 -
uva529 迭代加深+必要剪枝
//// main.cpp// 529//// Created by Fangpin on 15/3/14.// Copyright (c) 2015年 FangPin. All rights reserved.//#include #include using namespace std;int a[10005]={1,2},n;bool ok;void dfs原创 2015-03-15 13:11:50 · 810 阅读 · 0 评论 -
EOJ1154 CAN YOU DFS? IDA*搜索算法
题目:EOJ1154 CAN YOU DFS? IDA*搜索算法Description在古埃及,人们使用单位分数的和(形如1/a的, a是自然数)表示一切有理数。 如:2/3=1/2+1/6,但不允许2/3=1/3+1/3,因为加数中有相同的。对于一个分数a/b,表示方法有很多种,但是哪种最好呢? 首先,加数少的比加数多的好,其次,加数个数相同的,最小的分数越大越好。原创 2014-12-27 10:21:40 · 1338 阅读 · 0 评论 -
EOJ 1816 判断图连通的三种方法——dfs,bfs,并查集
题目:eoj1816 题目分析:判断图是否连通,可用dfs遍历图算法。这里我采用的是并查集的方法。初始化时将每个节点看作一个集合,则每给出一条边即把两个集合合并。最后遍历所有点,有几个集合便有几个连通分量,若只有一个集合说明图连通。 AC代码:#include #include #include #include #include #include原创 2014-12-24 18:42:39 · 6915 阅读 · 3 评论 -
EOJ1148
质数阵 Time Limit:2000MSMemory Limit:30000KBTotal Submit:565Accepted:152Description在N*N的棋盘上(1例如,当N=2时,有 1 2 4 3 Input 每组测试数据一行,为一整数N(1Output输出满足条件的最小序列的方案。 最小序列即原创 2014-12-06 23:11:06 · 1022 阅读 · 0 评论 -
eoj1120 dfs
Peg Game Time Limit:1000MSMemory Limit:30000KBTotal Submit:254Accepted:97Special Judge DescriptionYou are given a 7-by-7 board of holes. Some holes are filled with pegs, and some are原创 2014-12-06 23:09:47 · 932 阅读 · 0 评论 -
EOJ2253
A Knight's JourneyTime Limit:1000MSMemory Limit:65536KBTotal Submit:209Accepted:80DescriptionThe knight is getting bored of seeing the same black and white squares again and again an原创 2014-12-06 23:25:42 · 1107 阅读 · 0 评论 -
eoj1114
素数环 Time Limit:1000MSMemory Limit:30000KBTotal Submit:413Accepted:243Description一个由自然数 1..n (n 1/ 4 2/3Input输入只有一个数n,表示你需要建立一个1..n的素数环。 Output按照字典序输原创 2014-12-06 23:07:40 · 743 阅读 · 0 评论 -
poj 1077 八数码
用a*算法没有想到怎么优化每个节点状态需要复制上次状态的代价,导致tle。使用ida* ,但是bound上界是靠直观感觉,并没有想到合适的估算方法ida*// poj 1077 八数码 IDA*#include #include #include #include #include #include #include #include #include #inc原创 2015-09-24 12:15:22 · 602 阅读 · 0 评论