上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 41 下一页
摘要: 传送门 二位前缀和DP大水题 ——代码 1 #include <cstdio> 2 #include <iostream> 3 4 const int MAXN = 5010; 5 int n, r, ans; 6 int sum[MAXN][MAXN]; 7 8 inline int read() 阅读全文
posted @ 2017-05-27 14:51 zht467 阅读(162) 评论(0) 推荐(0)
摘要: 传送门 想了个4次方算法,没想到也A了,数据真是水。 其实两个字符串匹配那部分可以用kmp优化 ——代码 1 #include <cstdio> 2 #include <cstring> 3 4 int n, m, f[310]; 5 char s[310], a[501][310]; 6 7 in 阅读全文
posted @ 2017-05-27 06:52 zht467 阅读(198) 评论(0) 推荐(0)
摘要: 传送门 f[i][S] 表示当前集合为 S,最后一个数为 i 的最优解 f[i][S] += f[j][S - i] (j, i ∈ S && j != i && abs(a[i] - a[j]) > k) ——代码 1 #include <cstdio> 2 #include <iostream> 阅读全文
posted @ 2017-05-27 06:26 zht467 阅读(141) 评论(0) 推荐(0)
摘要: 传送门 树上前缀和。 在树上找一条权值和为 s 的链,其中这个链上的点按深度递增(递减)(不同) dfs 每搜到一个点求它的前缀和 sum[x],放入 set 中。 在 set 中找 sum[x] - s 的点,如果有,ans++ 退出 dfs 的时候再把 sum[x] 从 set 中删除 因为每个 阅读全文
posted @ 2017-05-26 20:54 zht467 阅读(126) 评论(0) 推荐(0)
摘要: 传送门 输出被阉割了。 只输出最少分的组数即可。 f 数组为结构体 f[S].cnt 表示集合 S 最少的分组数 f[S].v 表示集合 S 最少分组数下当前组所用的最少容量 f[S] = min(f[S], f[S - i] + a[i]) (i ∈ S) 运算重载一下即可。 ——代码 1 #in 阅读全文
posted @ 2017-05-26 20:09 zht467 阅读(170) 评论(0) 推荐(0)
摘要: 传送门 二位费用背包 ——代码 1 #include <cstdio> 2 #include <iostream> 3 4 int n, maxv, maxw; 5 int f[410][410]; 6 7 inline int read() 8 { 9 int x = 0, f = 1; 10 c 阅读全文
posted @ 2017-05-26 19:15 zht467 阅读(123) 评论(0) 推荐(0)
摘要: 传送门 深搜加剪纸可A(O(玄学) 1274ms) ——代码 1 #include <cmath> 2 #include <cstdio> 3 #include <iostream> 4 5 int n; 6 double ans = ~(1 << 31), a[16], b[16]; 7 bool 阅读全文
posted @ 2017-05-26 18:02 zht467 阅读(143) 评论(0) 推荐(0)
摘要: 传送门 这个题类似于建筑抢修。 先按照时间排序。 如果当前时间小于任务截止时间就选, 否则,看看当前任务价值是否比已选的任务的最小价值大, 如果是,就替换。 可以用优先队列。 ——代码 1 #include <queue> 2 #include <cstdio> 3 #include <iostre 阅读全文
posted @ 2017-05-26 14:53 zht467 阅读(212) 评论(0) 推荐(0)
摘要: 传送门 经典问题。 找出最大的不包含 1 的正方形。 f[i][j] 表示 以 (i,j) 结尾的最大的不包含 1 的正方形 f[i][j] = min(f[i - 1][j], f[i][j - 1], f[i - 1][j - 1]) + 1 画个图意会一下 ——代码 1 #include <c 阅读全文
posted @ 2017-05-26 14:12 zht467 阅读(148) 评论(0) 推荐(0)
摘要: 传送门 简单贪心 ——代码 1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 5 int n, l, r; 6 struct node 7 { 8 int x, y; 9 }p[50001]; 10 11 inlin 阅读全文
posted @ 2017-05-26 13:58 zht467 阅读(163) 评论(0) 推荐(0)
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 41 下一页