- 博客(22)
- 资源 (1)
- 收藏
- 关注
原创 hdu 4109 Instrction Arrangement 拓扑排序 关键路径
/*给定一个关系网,A B C表示B必须在A后,间隔为C,允许多线程同时操作最后求最短的时间把所有任务完成解法:关键路径topsort维护每个节点最早可以完成的时间*/#include#include#include#include#includeusing namespace std;struct node{ int y,t;}edge[10009];in
2011-10-30 21:30:22 1859 3
原创 hdu 4107 Gangster 线段树
/*操作a b c:[a,b]区间上的节点加上c,若节点的值已经超过P(包括等于),则加上2*c最后求每个节点的值和hdu3954很类似,具体参考:http://blog.csdn.net/wsniyufang/article/details/6702560每个区间设定min_dis;当区间中有一个点超过P时,释放lazy*/using namespace std;const in
2011-10-30 21:26:01 1381
原创 poj 3849 Settlers of Catan 模拟
#include #include #include #include #include #include #include #include using namespace std; int in[7]; int C[78]; int d[10009]; void init() { C[0]=1; for
2011-10-28 23:37:31 1185
原创 poj 3844 Divisible Subsequences 组合数学
/*参看http://blog.csdn.net/wsniyufang/article/details/6666169*/#include #include int f[1000005]; __int64 ans; int main() { int i,j,k,t,n,d; scanf("%d",&t); while(t--){
2011-10-28 23:27:03 1008
原创 poj 3850 Simple Polygon
/*题意:给定一些点,求一个点的序列,按照这个序列连接点(首尾也相连)使得形成一个多边形(既任意连线和其他线不想交)直接极角排序就好了,注意共线的情况,除了在起始位置距离极点小的在前,其他位置距离极点远的在前*/#include #include #include #include const int MAXN = 2009; const double eps
2011-10-28 23:19:43 1096
原创 POJ 3842 An Industrial Spy
/*筛出10000000内的素数显然是不可行的;筛出3400内的素数来检测10000000以内的数就ok了另外已经搜索过的数用used标记,下次碰到标记过的就不在判断,剪掉很多。*/#include #include #include #include #include #include #include using namespace std;
2011-10-28 23:13:22 1317 1
原创 HDU 3756 Dome of Circus 三分
/*底面为xy平面和轴为z轴的圆锥,给定一些点,使得圆锥覆盖所有点并且体积最小点都可以投射到xz平面,问题转换为确定一条直线(交x,z与正半轴)使得与x的截距r和与z轴的截距h满足h*r*r最小。三分,对于确定的h可以找到最佳的r,并且h*r*r的曲线必定只有一个极小值*/struct po{ double x,y;}p[10005];const double eps=1
2011-10-27 11:02:59 1829
原创 HDU 3760 Ideal Path 最短路spfa+BFS 字典序最小的最短路
/*题意:给定无向图(有重边)每条边有一种颜色,边权为1,让你找到从1到n的最短路,并且经过的边的颜色组成的序列的字典序最小。解答:1 分别spfa求出所有点到1和n的最短路d[0][i],d[1][i](可能经过的边u-v满足d[0][u]+1+d[1][v]=d[0][n])。 2 bfs搜索最小的字典序序列,找出C[step]的最小颜色序号*/const int M
2011-10-27 10:46:11 1483
原创 09 harbin现场赛 DLX
/*0代表可以填任意数e代表只能是奇数o代表只能填偶数相同字母的格子必须是同一个数e,o,0是同样处理的,只不过e,o加入奇数或偶数,0加入全部的1-9检查符合上述要求的解是否符合同字母同数字即可*/#include#include#include#includeusing namespace std;const int Row=9;const int MAX_COL
2011-10-20 11:26:55 974
原创 HDU 3231Box Relations 拓扑排序
/*分别对x,y,z topsort就ok了注意有公共部分的时候的建边*/#include #include #include #include #include #include #include #include #includeusing namespace std;int n,r;char s[3];int x,y;int inx[1009*2];int
2011-10-20 11:16:15 1375
转载 HDU 3234 Exclusive-OR 并查集变形
/* 转自:http://www.cppblog.com/Yuan/archive/2010/09/02/125667.html?opt=admin稍许改写 有n(n<=20000)个未知的整数X0,X1,X2Xn-1,有以下Q个(Q<=40000)操作: I p v :告诉你Xp=v I p q v :告诉你Xp Xor Xq=v Q k p1 p2 …
2011-10-20 11:11:39 1749 1
原创 hdu 3498 Dancing link 重复覆盖
# include # include # define N 60 # define V N*N int L[V],R[V];//记录左右方向的双向链表 int U[V],D[V];//记录上下方向的双向链表 int C[V];//指向其列指针头的地址 int H[
2011-10-13 22:36:57 1029
原创 HDU+2295+Dancing+link++++二分
# include # include # include # define N 60 # define V N*N int L[V],R[V];//记录左右方向的双向链表 int U[V],D[V];//记录上下方向的双向链表 int C[V];//指向其列指针头
2011-10-13 17:56:27 931
原创 HDU 3529 Dancing link 重复覆盖
#include#include#include#define M 32#define N 256int n,m;const int V=M*N;int U[V],D[V],C[V],R[V],L[V];int S[M],H[N];char s[M][M]
2011-10-13 17:18:01 732
原创 poj 3133 插头Dp
poj3133#include #include #include using namespace std;const int hash_size=60007;const int INF=100000;int n, m;int map[20][20];int
2011-10-11 15:24:27 1408
原创 集训队例赛——20111009 解题报告
//先上代码,注释稍后奉上。。。/*1010典型线段树*/#include #include #include #include#includeusing namespace std;struct Tree{ int L,R,v; int flag
2011-10-09 22:30:08 775
原创 Dancing Link 精确覆盖模版
#include#include#includeconst int Row=9;const int MAX_COLOUMN = Row*Row*4+2;//最多出现列数const int MAX_ROW = Row*Row*Row+2;//最多出现的列数 int c
2011-10-09 18:17:35 686
原创 poj 3076 Dancing Link
#include#include#include#include#include#include#includeconst int MAX_COLOUMN = 16*16*16;//最多出现列数const int MAX_ROW = 16*16*16+2;//最多
2011-10-09 17:38:12 930
原创 HDU 3065 病毒侵袭持续中 AC自动机
/*很裸的AC自动机, 关键是如何去掉模式串中的不相干字符 */ #include #include #include #include #include #include using namespace std; const int kind = 26;
2011-10-01 21:01:56 637
原创 hdu 2896病毒侵袭 && hdu 3695 Computer Virus on Planet Pandora AC自动机
/*2896很裸的AC自动机,注意判重就ok了 */ #include #include #include #include #include #include using namespace std; const int kind = 128;set S
2011-10-01 20:28:56 1113
转载 AC自动机理论与实现
来自:http://blog.sina.com.cn/s/blog_69c3f0410100tztt.html首先简要介绍一下AC自动机:Aho-Corasick automation,该算法在1975年产生于贝尔实验室,是著名的多模匹配算法之一。一个常见的例子就是给
2011-10-01 17:40:35 709
原创 HDU 1277 HDU 2222 AC自动机模版题
/* 给定一个母串和一些子串,找出哪些子串在母串中出现过,输出这些子串的编号 */ #include #include #include using namespace std; const int kind = 10; int ans[
2011-10-01 17:39:00 937
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人