摘要: 参考:http://hi.baidu.com/ccsu_010/item/7847a3c17f6fe2bc0d0a7b89关键是状态转移,矩阵就是解决状态转移的!(比较难)数据量:1 #include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o q;//保存的节点下标 f[0]=0; for (int c=0; c>=1; } memcpy(ma,temp,sizeof... 阅读全文
posted @ 2013-10-17 10:22 baoff 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance.The Hamming distance between two stringss = s1s2...snandt = t1t2...tnof equal lengthnis value. Record[si ≠ ti]is the Iverson notation and represents the following: ifsi ≠ ti, it is one, otherwise — zero.Now 阅读全文
posted @ 2013-10-16 20:02 baoff 阅读(240) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#define tree int o,int l,int r#define lson o>1; build(lson); build(rson); }}void init(){ memset(val,0,sizeof(val[0])*(n+1)); memset(lazy,0,sizeof(lazy)); build(1,1,n); return ;}void pushup(int o){ minx[o]=min(minx[lo],minx[ro]);}void pushdown(i... 阅读全文
posted @ 2013-10-15 09:49 baoff 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 和经典的线段树区间lazy操作相比,区间传递的是经验系数,每个点对系数的反应是不一样的,所以向下传递的时机有所改变,不但在区间被剖分时要向下释放,在该区间有某个点要升级的时候也要释放,因为此时用区间的lazy值叠加的话会影响结果,所以此时要释放lazy,lazy只有在这个区间的点都没到达升级门槛时才可以叠加。#include#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o>1 阅读全文
posted @ 2013-10-14 21:48 baoff 阅读(213) 评论(0) 推荐(0) 编辑
摘要: Vasya's got a birthday coming up and his mom decided to give him an array of positive integersaof lengthn.Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as beautiful an array as possible (with largest possible bea 阅读全文
posted @ 2013-10-14 17:09 baoff 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 题意:有一只怪兽,在白天攻击一次能损失它pd点血,晚上攻击则损失它pn点血,每次攻击的间隔为t,每天的白天时间与晚上时间分别为t1i, t2i,问N天内最多攻击它多少血。n #include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o=t) { for(int i=t,j=m; i>=1; i--,j--) { int s=j%t; ... 阅读全文
posted @ 2013-10-12 21:07 baoff 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 做提前一定要先比较KMP和哈希哪个更简单!!Letsbe a string whose length equalsn. Its characters are numbered from 0 ton - 1,iandjare integers,0 ≤ i #include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o>1; if(fa[mid]==hb[i+mid-1... 阅读全文
posted @ 2013-10-12 19:49 baoff 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 题意:if at some time thei-th position has a boy and the(i + 1)-th position has a girl, then in a second, thei-th position will have a girl and the(i + 1)-th one will have a boy求什么时候不在交换(时间)D. QueueThere arenschoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The b 阅读全文
posted @ 2013-10-11 20:53 baoff 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 题目大意:有多个政策,每个政策里面有很多子网,E 表示加入一个政策,D表示禁止一个政策,F就是询问ip1,ip2是不是在同一个政策中。思路:子网有个特点前缀相同,对于E操作,不难想到用字典树来维护所有子网(即ip的前缀),每个节点用一个vector保存该子网(即前缀)所属于的所有政策的标号。对于D操作,我们用一个数组维护该政策可不可用,对于F就是先把ip1所在的政策做一下标记,然后让ip2所在的政策有没有在这些标记中的即可。//#pragma comment(linker, "/STACK:102400000")#include#include#include#includ 阅读全文
posted @ 2013-10-11 18:23 baoff 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #include int f[10][10][10];bool vis[10][10][10];int dp(int a, int b, int c) { if (vis[a][b][c]) return f[a][b][c]; int& ans = f[a][b][c]; vis[a][b][c] = true; for (int i = 0; i < b; ++i) if (!dp(a, i, c)) return ans = 1; for (int i = 0; i < c; ++i) if (... 阅读全文
posted @ 2013-10-08 19:36 baoff 阅读(206) 评论(0) 推荐(0) 编辑