上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 42 下一页
找出若干个环覆盖所有的点,使得总的花费最小因为每个点只能经过一次,所以很快就可想到拆点求最小费用流建图:S->i 费用为0 流量为1i+n->T同上若有边u->vu->v+n 费用为边权,容量为1最后套套模板求一次最小费用流,如果流量等于n,表示每个点都遍历了一次,输出最小费用即可View Code #include <iostream>#include <algorithm>#include <string>#include <stdio.h>#include <string.h>#include <s Read More
posted @ 2012-03-26 11:20 Because Of You Views(861) Comments(0) Diggs(0) Edit
从网上找的模板,测试了一下View Code #include <iostream>#include <algorithm>#include <string>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <memory.h>#include <queue>#include <vector>#include <cmath>using namespace std;int sumFlow;const Read More
posted @ 2012-03-26 11:14 Because Of You Views(817) Comments(0) Diggs(0) Edit
判断1*2的砖块去填m*n的矩形总共的摆放方案dp[i][j]表示当前行状态为j时的总共的摆放方案先枚举上一层i的状态,如果存在某状态,就把还空的位置用竖的砖块插入,插满后,记录下当前i+1行的状态然后在i+1行暴力枚举所有可能摆放方案,这个状态数再叠加上同一行上一个的状态(没有摆放横砖块之前)总数最后的答案就是 dp[h][(1<<w)-1]即DP到最后一行,且摆满#include<stdio.h>#include<string.h>int h,w;__int64 dp[15][2050];void dfs2(int row,int state,int c Read More
posted @ 2012-03-25 21:59 Because Of You Views(853) Comments(0) Diggs(0) Edit
View Code #include<cstdio>#include<cstring>int hash[2000010];int main(){ int a,b,c,d,i,j; while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF) { if( (a>0 && b>0 && c>0 && d>0 )|| (a<0 && b<0 && c<0 && d&l Read More
posted @ 2012-03-25 04:15 Because Of You Views(322) Comments(0) Diggs(0) Edit
第一次设计哈希函数,乱YY的,哈希函数细微的不同时间差距很大啊,我交了n遍。。。disscuss中的哈慈函数好强大。。x,y映射到一个哈希值,有可能会有多个值具有同一哈希值,所以建立邻接表,哈希函数的目的就是让尽量少的数拥有同一个哈希值也就是尽可能的分散,尽可能的做到一一映射,就做了这题我就感觉哈希好强大啊这是我看别人的代码后的理解,不知道对不对感觉是对的,因为能A题,呵呵。题目中已知两个点(相邻),可以求出正方形的另外两个点http://iaml.is-programmer.com/posts/7923.html已知两个点,可以得出得出另外两个点 (x1+|y1-y2|, y1+|x1-x2 Read More
posted @ 2012-03-25 03:42 Because Of You Views(404) Comments(0) Diggs(0) Edit
View Code const int maxn = 100000;const double eps = 1e-8;const double pi = acos(-1.0);#define sgn(x) (fabs(x)<eps?0:(x>0?1:-1))struct Point { double x, y; Point(double a=0,double b=0){x=a;y=b;} Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp... Read More
posted @ 2012-03-25 01:07 Because Of You Views(443) Comments(0) Diggs(0) Edit
主要内容是计算几何,利用了一个图论中的结论平面的区域个数 r=m-n+2,m为边数、n为点数心血来潮,决定不用别人的模板,手写了模板1:判断线段相交2:判断点在线段上都是些最基本的,不过这些以后就算我自己的啦,用别人的总感觉怪怪的View Code #include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int maxn = 100000;const double eps = 1e-8;const double Read More
posted @ 2012-03-25 00:57 Because Of You Views(300) Comments(0) Diggs(0) Edit
判断一个多边形能否放进凸包中对所有点再做一次凸包,把重点和共线点都加进凸包集合中如果图暴集合中有某个点是多边形的点就输出noelse yesView Code #include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef __int64 lld;const double eps = 1e-8;const double pi = acos(-1.0);struct Point { lld x, y; int id; Read More
posted @ 2012-03-24 19:14 Because Of You Views(372) Comments(0) Diggs(0) Edit
题意:某个冰块上有a只企鹅,总共可以跳出去b只,问是否可能所有的企鹅都跳到某一块冰块上,输出所有的可能的冰块的编号。由于每个点只能跳出去m只企鹅,所以要拆点假如不拆点,一个点到另一个点可能会跳多于m只企鹅通过拆点后u->u'间的容量来完成题目的要求(对点的一些限制)建图:i->i+n 容量为m i+n->j容量为INF新建源点s,s->i的容量为i点企鹅的个数然后枚举汇点求最大流就可以判断某个点是否符合条件View Code #include<stdio.h>#include<cmath>#include<string.h># Read More
posted @ 2012-03-24 01:22 Because Of You Views(731) Comments(0) Diggs(0) Edit
http://www.acdream.tk/problem.php?cid=1001&pid=1dp[i] 表示匹配前i个字符的最大权值View Code #include<stdio.h>#include<string.h>#include<queue>using namespace std;class trie{public : int num; trie* child[27]; trie() { num=0; memset(child,0,sizeof(child)); }}root;void insert(char *s,int... Read More
posted @ 2012-03-23 21:11 Because Of You Views(370) Comments(0) Diggs(0) Edit
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 42 下一页