码迷,mamicode.com
首页 >  
搜索关键字:zoj bfs    ( 8652个结果
ZOJ 3717
这题是二分+2SAT.总结一下SAT题的特征。首先,可能会存在二选一的情况,然后会给出一些矛盾。据这些矛盾加边,再用SAT判定。这一道题好像不能直接用printf("%0.3lf"),因为这个是四舍五入的,这道题好像不能四舍五入,只好选减去0.0005再按这个格式输出了。 1 #include .....
分类:其他好文   时间:2014-07-22 22:49:32    阅读次数:214
POJ 3984
通过BFS解决迷宫问题,再利用一个last[]数组由出口倒置回来不断找到上一个点的位置,最终返回入口,而得到这条最短路径代码: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int map[5][5]; 8 int d.....
分类:其他好文   时间:2014-07-21 10:02:02    阅读次数:204
ZOJ 1232 Adventure of Super Mario SPFA+DP
第一次做类似的题目,卡了好几天,最后看了爱酱的blog(http://blog.csdn.net/acm_cxlove/article/details/8679230)才会的,sad题意大概是这样,给你一个图,求起点1到N的最短时间,你有一双鞋子,可以加速,一次性花费0的时间行走M单位的路程,但是鞋...
分类:其他好文   时间:2014-07-21 10:00:38    阅读次数:242
Frame Stacking ZOJ 1083,poj 1128
Frame StackingTime Limit:1000MSMemory Limit:10000KTotal Submissions:4034Accepted:1352DescriptionConsider the following 5 picture frames placed on an 9...
分类:其他好文   时间:2014-07-21 00:04:17    阅读次数:399
Zoj 2027 Travelling Fee 最短路变形
给你一个图和AB,问你从A到B的路径中,当每条路径的最长的边长度忽略的情况下,A到B的最短路.建立两个矩阵,一个记录最大长度,一个是最短路,同步更新即可.#include #include #include #include #include #include #include #include #...
分类:其他好文   时间:2014-07-21 00:02:02    阅读次数:196
poj 3026 Borg Maze (bfs + 最小生成树)
链接:poj 3026 题意:y行x列的迷宫中,#代表阻隔墙(不可走),空格代表空位(可走),S代表搜索起点(可走) A代表外星人站(可走),现在要从S出发,将S和所有的A之间都连通,求路线总距离最小值 分析:可以先用bfs将所有的A,S两两之间的最短距离,题目的目的是将S与所有的A连通,使得总距离最小, 所有任选一点开始按最小生成树的算法做就行,并非非要从S点开始...
分类:其他好文   时间:2014-07-20 23:26:40    阅读次数:374
最长公共上升子序列(LCIS)ZOJ 2432
立方算法: #include #include #include #include #define M 505 using namespace std; typedef long long LL; LL a[M],b[M]; int dp[M][M]; int main() { //freopen("in.txt","r",stdin); int T; cin>>T; ...
分类:其他好文   时间:2014-07-20 23:01:50    阅读次数:284
【leetcode】com/problems/surrounded-regions/
dfs 栈溢出,bfs超时,用dfs非递归就不溢出了,前后写了1一个星期class node{ int i; int j; public node(int i1,int j1) { i=i1; j=j1; ...
分类:其他好文   时间:2014-07-20 22:32:17    阅读次数:244
POJ3026——Borg Maze(BFS+最小生成树)
Borg MazeDescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the ter...
分类:其他好文   时间:2014-07-20 22:28:43    阅读次数:253
zoj 2876 Phone List
#include #include #include #define ZERO 0 const int FIRST_CHAR = '0'; char num[11111][20] ; typedef struct node { struct node *child[20]; /* 存储下一个字符 */ int n; /* 记录当前单词出现的次数 */ }node, *No...
分类:其他好文   时间:2014-07-20 11:32:38    阅读次数:215
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!