2012年8月18日

HDU 3486 RMQ + 二分

摘要: 算法:1.RMQ 求区间最值2.二分枚举段的数量,注意是段的数量和其和成正比,也就是枚举段的数量。View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<vector>#include<string>#include<math.h>#include<map>#include<set>#include<algorithm>using namespace s 阅读全文

posted @ 2012-08-18 17:31 more think, more gains 阅读(138) 评论(0) 推荐(0) 编辑

多米诺骨牌 优化版

摘要: 算法:在之前搜索出状态的基础上,再压缩一次状态。View Code //by yefeng#include<iostream>using namespace std;typedef long long LL; const int mod = 9937;int mask,idx, n , m;struct Matrix{ int mat[257][257]; void zero() { memset(mat,0,sizeof(mat)); } void unit(){ memset(mat,0,sizeof(mat)); fo... 阅读全文

posted @ 2012-08-18 16:38 more think, more gains 阅读(207) 评论(0) 推荐(0) 编辑

HDU 4332 Constructing Chimney 矩阵快速幂

摘要: 算法:1.状态压缩2.搜索3.矩阵快速幂View Code #include<iostream>using namespace std;typedef long long LL;const int mod = 1000000007;const int mask = 255;struct Matrix{ LL mat[100][100]; void unit(){ memset(mat,0,sizeof(mat)); for(int i = 0; i < 100; i++) mat[i][i]=1; } void zero(){... 阅读全文

posted @ 2012-08-18 16:37 more think, more gains 阅读(172) 评论(0) 推荐(0) 编辑

B.寻找最大值

摘要: 算法:1.正向思维如果枚举区间求最值肯定TLE,数据量很大。2.反向思维,枚举每个点的左右区间,虽然两个for循环,我感觉是平均是O(N)的时间复杂度,动态规划的思想,可以求出。3.这题相当诡异,不能给dt数组清空赋值,坑了我一晚上加上午,还不知道为什么。4.我的L[I]记录的是该点能往左到达的边界,R【i]是往右到达的边界。旭他们记录的是以该点向左能扩张的长度,R【i]类似。View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#incl 阅读全文

posted @ 2012-08-18 09:38 more think, more gains 阅读(174) 评论(0) 推荐(0) 编辑

导航