上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 48 下一页
  2012年9月22日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1389一维树形DP 不难 关键在于输出类似路径的选择求完最优答案 再顺着答案走一遍就可以了关键:从一个节点出发的各条 road 中 如果某一条 road 被 block 则相连的下一个节点开始的路都不能进行 block如果某一条路没有被 block 则相连下一个节点开始的路可以进行选择性的是否 block但要注意从一个点出发的 road 最多只能有一个block代码及其注释:#include <iostream>#include <cstdio>#include < 阅读全文
posted @ 2012-09-22 10:58 夜-> 阅读(267) 评论(0) 推荐(0) 编辑
  2012年9月21日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1577递推 DP代码及其注释:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000")using 阅读全文
posted @ 2012-09-21 18:47 夜-> 阅读(209) 评论(0) 推荐(0) 编辑
  2012年9月20日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4291找循环节 + 矩阵连乘代码:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000")using name 阅读全文
posted @ 2012-09-20 19:49 夜-> 阅读(168) 评论(0) 推荐(0) 编辑
  2012年9月19日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4297此题目中的图是一个特殊的森林 特殊在于它的树都有一个环 这个环内点包括树根基本思路:先用并查集 对图进行处理1 建立完整森林2 构成环的边不加入森林3 记录每个环上有多少点 每个环上点属于第几个环然后处理 couples不在一个树上的不可达同一个 room 内 特别处理将 couples 储存然后LCA 这里LCA 与原始LCA 有不同如果最近公共祖先不在环上 直接求出 如果在环上 求其分别是环上哪一个点过来的最后就好处理了对不同方案进行选优代码及其注释:#include <iostream> 阅读全文
posted @ 2012-09-19 20:49 夜-> 阅读(247) 评论(0) 推荐(0) 编辑
  2012年9月17日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4289唉 本来对网络流的题目就不是很擅长 而且最近也没去碰这方面的题结果这次有两个用最大流的 而且都是拆点的 伤不起呀这个题把每个点拆成两个点 一个入点 一个出点入点到出点流就为 所给费用 出点到入点流为 0对于相连的点 相互之间都是 I 点的出点到 J 点的入点流为最大 J 点的入点到 I 点的出点流为0将 I 点和 J 点对换再建一次最后Dinic代码:#include <iostream>#include <cstdio>#include <cstring>#incl 阅读全文
posted @ 2012-09-17 18:37 夜-> 阅读(230) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4296此题仅需用 w+s 的值进行从小到大的排序即可 注意 结果可能超32位证明 只需要证明相邻的即可 因为它们不会影响前面的PDV 也不会影响后面的PDV假设 w1+s1 < w2+s2 在此之前的的w和为 X那么 w1+s1 在前则 最大PDV 为 P1=max(X-s1,X+w1-s2);如果 w2+s2 在前则 最大PDV 为 P2=max(X-s2,X+w2-s1);我们可以同时把X去掉 则P1=max( -s1,w1-s2);P2=max( -s2,w2-s1);再将所有值加上 s1+s2 阅读全文
posted @ 2012-09-17 17:27 夜-> 阅读(186) 评论(0) 推荐(0) 编辑
  2012年9月16日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1287我说Timus 你还能再水一些吗 递推 + 滚动数组代码:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000")using names 阅读全文
posted @ 2012-09-16 10:04 夜-> 阅读(181) 评论(0) 推荐(0) 编辑
  2012年9月15日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4280最大流 应该是考 ISAP 的题 但是Dinic 也能过 但是要看人品自己只会写Dinic 所以就把Dinic 很多小的地方不断优化 终于6000+ms过了但这并不是目的 有时间还是要好好看看ISAP的代码:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <algorithm>#define LL long long//外挂开栈#pra 阅读全文
posted @ 2012-09-15 17:35 夜-> 阅读(193) 评论(0) 推荐(0) 编辑
  2012年9月14日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4284这题后台数据相当强呀思路:先用flody 求得任意两点间的最短距离然后再用 状态压缩+DPdist [ i ] [ j ] 表示已经到 i 状态压缩表示的城市 拿到证件 打工 而且现在在 第 j 个要去的城市 这种情况下剩余的最多钱不断更新 最后看是否有满足条件 去过所以要去的城市 而且还能回到原点的 状态代码及其注释:#include <iostream>#include <cstdio>#include <cstring>#include <queue> 阅读全文
posted @ 2012-09-14 16:50 夜-> 阅读(138) 评论(0) 推荐(0) 编辑
  2012年9月12日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1080dfs 水题不解释#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#define LL long longusing namespace std;const int N=103;int head[N];struct node{ int j,next;}side[N*N];int I;int ans;int color[N];void build 阅读全文
posted @ 2012-09-12 16:54 夜-> 阅读(256) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 48 下一页