上一页 1 2 3 4 5 6 7 8 ··· 10 下一页
摘要: 题目链接:http://poj.org/problem?id=16361)DFS+DP法View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 const int MAX=210; 6 int map[MAX][MAX]; 7 int vist[3][MAX]; 8 int dp[MAX][MAX]; 9 int asize,bsize;10 int m,r;11 void init()12 {13 memset(dp, 阅读全文
posted @ 2012-04-03 13:41 我们一直在努力 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3352题目大意就是求添加多少条边可以构成双连通图,利用了缩点,由于这里不会出现重边所以就简单的利用了low数组最终的标记数字,相同的为一个连通分量,不通说明不在一个连通分量 进行统计,也就是求缩点后剩余的点构成多少个节点的树(num),然后要加的边就是(num+1)/2;关于有重边的情况稍后是再做此类题。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio&g 阅读全文
posted @ 2012-04-01 19:55 我们一直在努力 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1523View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <stack> 5 using namespace std; 6 const int MAX=1030; //poj很神奇这里写成1025 就是wa 7 struct ss { 8 int v,next; 9 }edge[MAX];10 int head[MAX],DFN[MAX],low[MAX],subnet 阅读全文
posted @ 2012-03-31 16:11 我们一直在努力 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 转自scameeling的空间http://hi.baidu.com/scameeling/blog/item/60f25a8dc50347e3f01f36f0.html谢谢分享!! 阅读全文
posted @ 2012-03-30 15:49 我们一直在努力 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1577这也可以算是这次周赛最简单的题了,可是发现的太晚了,再有一分钟时间就好了。题意是:给你一些叶子节点,然后去掉叶子节点继续找叶子节点。而且所有节点的左子树小于它,右子树大于它,最后让你输出中序遍历。也就是对于每组数据有最后一组数据到第一组数据建树。树建成输出就ok了。View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using namespac 阅读全文
posted @ 2012-03-30 12:12 我们一直在努力 阅读(408) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3767核心算法 Dijkstra大意:N个城市,城市编号为1,2,3,……NM条路,路为双向路。 提供每条路的长度及端点城市编号,每两个城市之间直接连通的路最多一条。这N个城市分为两个集合,部分属于集合1,部分属于集合2,提供每个城市所属的集合,现要求从城市1出发去城市2,要求途径的路中最多出现一条其两端城市不属于同一个集合的路,求出符合该条件下的从城市1到城市2的最短路,若不存在符合条件的路,输出-1注:数据中城市1必定属于集合1,城市2必定属于集合2分析:由于城市1与城市2所属的集合固定,故在路径中必定有一条而且只能有一条路从 阅读全文
posted @ 2012-03-30 10:38 我们一直在努力 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1827trajan算法看明白了,不过这道题的做法还是有点不是太懂,看了其他的博客才ac的。主要就是找连通分量的个数和连通分量的root(入度为零的点),并计算到每个连通分量的最小值。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cmath> 5 #include <stack> 6 using namespace st 阅读全文
posted @ 2012-03-29 14:37 我们一直在努力 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4600题目意思很简单,但一般的方法会超时的。这里用的是DP看解题报告做不来的....View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cmath> 5 using namespace std; 6 struct ss{ 7 int a,b,h,x,y; 8 }num[1005]; 9 int judg 阅读全文
posted @ 2012-03-27 21:19 我们一直在努力 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1121给个解题报告吧http://rchardx.is-programmer.com/posts/16142.html这题周赛是 没思路View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 int num[105][105]; 6 int main() 7 { 8 int k,i,j,n,m; 9 scanf("% 阅读全文
posted @ 2012-03-26 09:42 我们一直在努力 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1342这道题比赛时理解错了,想成了贪心,结果不断的wa, 其实如果每个车间生产的都是开始时间长以后短的话可以用贪心法做。但没这限制显然是不行的,要用DP。View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 7 double dp1[1001],dp2[ 阅读全文
posted @ 2012-03-25 18:29 我们一直在努力 阅读(195) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 10 下一页