摘要:
传送门 树上前缀和。 在树上找一条权值和为 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)
摘要:
传送门 由于 Di 只有 3 种情况,那么就很简单了 f[i][j][0] 表示前 i 个,且第 i 个变成 j 的 递增序列最小修改次数 f[i][j][1] 表示前 i 个,且第 i 个变成 j 的 递减序列最小修改次数 状态转移看代码。 ——代码 1 #include <cstdio> 2 # 阅读全文
posted @ 2017-05-26 11:12
zht467
阅读(259)
评论(0)
推荐(0)
摘要:
传送门 f[i] 表示送前 i 头牛过去再回来的最短时间 f[i] = min(f[i], f[j] + sum[i - j] + m) (0 <= j < i) ——代码 1 #include <cstdio> 2 #include <iostream> 3 4 const int MAXN = 阅读全文
posted @ 2017-05-26 10:45
zht467
阅读(102)
评论(0)
推荐(0)
摘要:
传送门 按价格排序后贪心 ——代码 1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 5 int n; 6 long long m, ans; 7 struct node 8 { 9 long long x, y; 阅读全文
posted @ 2017-05-26 10:27
zht467
阅读(154)
评论(0)
推荐(0)
摘要:
传送门 f[i] 表示前 i 个字符去掉多少个 的最优解 直接暴力DP ——代码 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 5 int n, m, cnt, f[301]; 6 char s[301], a[60 阅读全文
posted @ 2017-05-26 09:44
zht467
阅读(193)
评论(0)
推荐(0)

浙公网安备 33010602011771号