上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 48 下一页
  2012年7月20日
摘要: http://poj.org/problem?id=2411完全自己做的话 还真不行 能力还是不够呀横着的两个小格 和竖着的第一个小格用 0 表示 竖着的第二个小格用 1表示逐行更新 更新时用 DFS 最后一行要注意特判一下代码及其注释:#include<iostream>#include<stdio.h>#include<string.h>#include<queue>#include<cmath>#include<stack>#include<algorithm>#define LL long longus 阅读全文
posted @ 2012-07-20 19:48 夜-> 阅读(185) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3254poj 你又亮了 我感觉时间复杂度这么高的程序 你居然让我 0ms 过了无语了给你矩阵 有的地方可以种植 有的地方不可以种植位置不可相邻 问最多有多少种 种法最多宽度为12 把其中一维 的种不种 转化为 对应位 的二进制1 或0让后更新就可以了代码及其注释:#include<iostream>#include<stdio.h>#include<string.h>#include<queue>#include<cmath>#include<stack>#includ 阅读全文
posted @ 2012-07-20 16:08 夜-> 阅读(197) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3034n*n方阵 特定时间 特定位置有 moles 同一时间锤子可以 打一条直线上的moles直线最大距离为 d根据时间 逐层更新数量注意超出 d 范围的情况 和 锤子停留在方阵外的情况代码及其注释:#include<iostream>#include<stdio.h>#include<string.h>#include<queue>#include<cmath>#include<stack>#include<algorithm>using namespac 阅读全文
posted @ 2012-07-20 14:19 夜-> 阅读(211) 评论(0) 推荐(0) 编辑
  2012年7月19日
摘要: http://poj.org/problem?id=1925蜘蛛侠要从最左荡到最右荡的过程中不能着地 问最少荡多少次荡点 在荡的过程中高度不变要以 荡点(0...1000000)找最小答案进行更新代码及其注释:#include<iostream>#include<stdio.h>#include<string.h>#include<queue>#include<cmath>#include<stack>#include<algorithm>using namespace std;const int N=5005 阅读全文
posted @ 2012-07-19 20:55 夜-> 阅读(162) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2948矩阵中每个点都有 只能向north和向west传递的两种矿 二者不可兼得传到最north 和最 west 的矿才可获得 求最大DP 递推代码:#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int N=505;int tonorth[N][N];int towest[N][N];int sum[N][N];int main(){ int n, 阅读全文
posted @ 2012-07-19 10:51 夜-> 阅读(164) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2029给个大矩阵 上面有一些点再给个小矩阵 问小矩阵最大可以包含多少个点代码:#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int N=105;int a[N][N];int b[N][N];//x范围仅为1 y范围为 h 的和int sum[N][N];//x范围为w y范围为 h 的和int main(){ int n; int W,H; i 阅读全文
posted @ 2012-07-19 09:15 夜-> 阅读(187) 评论(0) 推荐(0) 编辑
  2012年7月18日
摘要: http://poj.org/problem?id=3280给一个字符串可以再任意位置添加或删除字母(给出花费的) 使得字符串变成回文思路:其实添加和删除的性质是一样的添加一个字母和删去相对应的字母 对于使原文变成回文的贡献是一样的 所以我们取花费的时候 只取小的花费为了理解方面统一用删除吧从两端进行遍历1 如果对应相等 则直接去掉就可以 (无需花费)2 如果只有一个字符了 直接去掉 (无需花费)3否则选择删掉左边 和 删掉右边 两种情况中最优的(只有给出花费才能删)代码及其注释:#include<iostream>#include<stdio.h>#include&l 阅读全文
posted @ 2012-07-18 21:32 夜-> 阅读(182) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1054天哪 为什么不超时 受不了啦直接暴力加优化就可以过呀枚举两点 找其他合适的点时 控制一下范围代码及其注释:#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int N=5005;struct node{ int x,y;}mem[N];int l[N];//记录x为i是左起位置int r[N];//记录x为i是右起位置bool cmp(node 阅读全文
posted @ 2012-07-18 20:19 夜-> 阅读(153) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1191DP 一不小心开了个五维数组double ans[k][x1][y1][x2][y2] 表示(x1,y1)到(x2,y2)可以割k次时与平均数最小平方和代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algorithm>#include<set>using namespac 阅读全文
posted @ 2012-07-18 14:48 夜-> 阅读(165) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1691拓扑排序+DFS把矩形的先后顺序 用拓扑排序构造再进行深搜+剪枝就可以啦代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algorithm>#include<set>using namespace std;const int N=21;struct node{ int x1 阅读全文
posted @ 2012-07-18 10:29 夜-> 阅读(126) 评论(0) 推荐(0) 编辑
上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 48 下一页