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
夜->
阅读(190)
评论(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
夜->
阅读(162)
评论(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
夜->
阅读(173)
评论(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
夜->
阅读(134)
评论(0)
推荐(0)
摘要:
http://poj.org/problem?id=3373DFS+强力剪枝伤不起呀 自己写怎么都写不出来 最后还看开了别人的解题报告思维能力还是不够呀推荐解题报告:http://blog.csdn.net/lyy289065406/article/details/6698787代码及其注释:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algorith 阅读全文
posted @ 2012-07-18 09:12
夜->
阅读(168)
评论(0)
推荐(0)
浙公网安备 33010602011771号