上一页 1 ··· 41 42 43 44 45 46 47 48 49 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1811思路:先处理‘=‘,全部合并为同一个节点,然后在拓扑排序就可以了。。。拓扑排序知识:*如果一次入队入度为零的点大于1则说明拓扑排序序列不唯一*如果排序的总个数小于给定的个数,则说明存在回路View Code 1 #define _CRT_SECURE_NO_WARNINGS 2 #include<iostream> 3 #include<cstdio> 4 #include<cstring> 5 #include<vector> 6 #inclu 阅读全文
posted @ 2013-04-18 16:49 ihge2k 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1116思路:先合并,然后判断根结点是否唯一,如果是,则在判断是否是欧拉路;否则,直接结束。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 const int MAXN=100000+10; 6 int In[MAXN],Out[MAXN]; 7 int parent[MAXN]; 8 bool mark[MAXN]; 9 i 阅读全文
posted @ 2013-04-17 20:49 ihge2k 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3986思路:先spfa求出最短路,然后枚举删除最短路上的边,每次删除一条边,就求一次最短路,然后去最大的那个就行了。。。可以重边的问题没考虑完善,wa了好多次啊!!!View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<vector> 5 using namespace std; 6 const int MAXN=1000+10; 7 const i 阅读全文
posted @ 2013-04-17 20:49 ihge2k 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3191题意:求出次短路的长度和条数View Code 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int MAXN=55; 8 const int inf=1vet[MAXN]; 13 struct Node{ 14 int v,dist; 15 int mark;//标记,1为最短路,2为次短路; 16 bool operator... 阅读全文
posted @ 2013-04-16 22:16 ihge2k 阅读(599) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2962思路:二分枚举高度,每次都sfpa一下,然后如果dist[e]存在的话,就更新shortpath...View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<vector> 5 #include<algorithm> 6 const int MAXN=1000+10; 7 const int inf=1<<30; 8 us 阅读全文
posted @ 2013-04-15 22:27 ihge2k 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2363思路:和之前hdu上做过的一题很像。。。就是先求求出所有的高度差,排序后枚举,每次都一次spfa,求出dist,若dist[n]!=inf,说明是在最小高度差下找到了最短路径,直接break即可。。。另外,发现若不用visited[]标记的话,时间是其两倍。。。orz....以后还是老老实实加visited [] 吧。。。View Code 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 阅读全文
posted @ 2013-04-14 20:30 ihge2k 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2377思路:对每个点spfa求一次最短路,每次求的时候都要用一个MAX_dist[]来保存当前点到各点的最短路径的最大值,然后这个数组中的min值就是star value了。。。View Code 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 const int MAXN=10000+10; 5 const int inf=1<<30; 6 using namespace std 阅读全文
posted @ 2013-04-14 20:30 ihge2k 阅读(243) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-04-14 18:29 ihge2k 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2145思路:题目很简单。。。关键是思想,如果你建图求的是每个点到终点的最短距离,那就TLE了,但仔细一想,我也可以建反向图啊!!!然后一次Dijkstra或者spfa就可以了。。。最后排序即可。View Code 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 #include<algorithm> 5 const int MAXN=333; 6 const int inf=1&l 阅读全文
posted @ 2013-04-14 10:16 ihge2k 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1839思路:先给容量从大到小排序,然后二分,每次都一次spfa一下,判断当前的cost[n]的值。。。View Code 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 typedef long long ll; 5 const int MAXN=10000+10; 6 const ll inf=1e60; 7 using namespace std; 8 struct Node{ 9 int 阅读全文
posted @ 2013-04-13 23:01 ihge2k 阅读(386) 评论(0) 推荐(0) 编辑
上一页 1 ··· 41 42 43 44 45 46 47 48 49 ··· 61 下一页