上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 99 下一页

2012年7月8日

poj 2965 枚举搜索

摘要: 这题跟POJ1753 flip game 思想一样。。唯一不同得是这题要保存方案。用c++一直超时,g++500多ms.View Code #include <stdio.h>#include <string.h>#include <iostream>#include <queue>#include <stack>using namespace std;int visit[70000];char mp[1100];struct node{ int state; int num;}p;struct pnode{ int x, y;}px 阅读全文

posted @ 2012-07-08 19:58 more think, more gains 阅读(139) 评论(0) 推荐(0) 编辑

poj 1753 Flip game 枚举

摘要: BFS搜索 + 位运算提速。。枚举每一个状态, 进行up, left, down, right操作。。当状态state = 0xffff 或0时,说明全部为黑或白。。。对于一个状态没有访问过就入队,并且标志为已访问。。View Code #include <iostream>#include <cstdlib>#include <stdlib.h>#include <string.h>#include <stdio.h>#include <queue>using namespace std;char mp[100];int 阅读全文

posted @ 2012-07-08 17:02 more think, more gains 阅读(148) 评论(0) 推荐(0) 编辑

2012年7月7日

网络流常用算法

摘要: 1.sap递归版。View Code #include <iostream>using namespace std;#define MAXN 10000struct Edge{ int v, next, val; Edge( ) { } Edge( int V, int N, int Val): v(V), next(N), val(Val) {} }edge[MAXN];int head[MAXN],size, flow, visit, sum, N, M, ans;int gap[MAXN], h[MAXN];/*sap算法核心:1.dfs搜索增广路2.标号 ... 阅读全文

posted @ 2012-07-07 17:01 more think, more gains 阅读(192) 评论(0) 推荐(0) 编辑

2012年3月24日

Alice's Chance poj 1698

摘要: 刚开始我是则这样构图的1.源点到1-7天的天数为最大的周数2.每天与其对应的演电影的时间连接,容量为其周数3.把每部电源的所有演出时间点再汇聚到一个节点(容量为inf),再把这个节点与汇点连边,容量为该部电源其所需天数。这样构图,一直wa, 早上起来才想到,没有考虑时间先后顺序。如这组测试数据331 1 1 1 1 1 1 105 151 1 1 1 1 1 1 14 21 1 1 1 1 1 1 7 20正确的构图应该这样, 把所有时间(那天可以演电影的对应一个点,最后得到一个时间的点集。20 1 0 1 0 1 0 9 31.构造时间的点集合为point = { day{ (week - 阅读全文

posted @ 2012-03-24 09:24 more think, more gains 阅读(166) 评论(0) 推荐(0) 编辑

2012年3月19日

hdu 3081 Marriage Match II

摘要: Sample Input14 5 21 1233 24 2441 42 3结合输入数据讲题意,1,就是一组输入数据,4表示有2 * 4个人,女生编号为1-4, 男生编号也为1-4,5表示下面接下来5对关系是没有吵过架的,2表示为有2对女生女生是好朋友的关系,也就是最后输入的那两行题目是要我们求每个女生找一个男生,并且这个男生没有和她吵过架,如果她朋友没有跟这个男生吵过架也可以。还有就是女生之间的朋友关系可以传递。但是不能找以前她已经找过的男生。。当每个女生找到一个男生后,这个游戏就算玩了一次,然后接着继续玩。要我们解决的问题是,这个游戏最多可以玩几圈。算法:1.并查集因为女生之间的朋友关系可以 阅读全文

posted @ 2012-03-19 22:54 more think, more gains 阅读(292) 评论(0) 推荐(0) 编辑

上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 99 下一页

导航