会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
shuguangzw
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
10
11
12
13
14
15
16
17
18
···
30
下一页
2016年5月6日
HDU4027 Can you answer these queries? 线段树
摘要: 思路:http://www.cnblogs.com/gufeiyang/p/4182565.html 写写线段树 #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> using namespace
阅读全文
posted @ 2016-05-06 15:56 shuguangzw
阅读(104)
评论(0)
推荐(0)
2016年5月5日
ZOJ3261 Connections in Galaxy War 并查集
摘要: 分析:对于这种删边操作,我们通常可以先读进来,然后转化离线进行倒着加边 #include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> using namespace std; typedef pair<
阅读全文
posted @ 2016-05-05 22:33 shuguangzw
阅读(132)
评论(0)
推荐(0)
POJ 1773 Parity game 带权并查集
摘要: 分析:带权并查集,就是维护一堆关系 然后就是带权并查集的三步 1:首先确定权值数组,sum[i]代表父节点到子节点之间的1的个数(当然路径压缩后代表到根节点的个数) 1代表是奇数个,0代表偶数个 2:设计路径压缩算法 sum[x]=(sum[x]+sum[t])%2; 3:弄清合并根节点时的操作,小
阅读全文
posted @ 2016-05-05 12:08 shuguangzw
阅读(213)
评论(0)
推荐(0)
POJ1456 Supermarket 贪心
摘要: 贪心策略:一定先卖价值最大的,然后考虑卖当前的物品,卖的日期越靠后,越优,可以为以后的物品提供机会 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N=1e4+5;
阅读全文
posted @ 2016-05-05 11:10 shuguangzw
阅读(113)
评论(0)
推荐(0)
POJ2492 A Bug's Life 带权并查集
摘要: 分析:所谓带权并查集,就是比朴素的并查集多了一个数组,记录一些东西,例如到根的距离,或者和根的关系等 这个题,权数组为relation 代表的关系 1 和父节点不同性别,0,和父节点同性别 并查集一个很大的方便在于它可以进行路径压缩,可以将树高维持在2(当然有一些其它应用是不需要路径压缩的) 这就需
阅读全文
posted @ 2016-05-05 10:48 shuguangzw
阅读(221)
评论(0)
推荐(0)
2016年5月4日
HDU 3038 How Many Answers Are Wrong 带权并查集
摘要: 分析:这一题和HDU3047一样,都是带权并查集,求后输入和先输入的冲突个数 然后其实就是用并查集维护一棵树,小的作为大的祖先,然后这棵树每个节点到根的路径权值是相对根节点的距离 这样就可以维护距离限制,判断冲突 #include <cstdio> #include <cstring> #inclu
阅读全文
posted @ 2016-05-04 19:54 shuguangzw
阅读(113)
评论(0)
推荐(0)
HDU3047 Zjnu Stadium 带权并查集
摘要: 转:http://blog.csdn.net/shuangde800/article/details/7983965 #include <cstdio> #include <cstring> #include <queue> #include <set> #include <map> #includ
阅读全文
posted @ 2016-05-04 19:49 shuguangzw
阅读(152)
评论(0)
推荐(0)
FZU2235 国王的出游 水题
摘要: 因为只有1e5个点,所以直接离散化bfs就好 #include <cstdio> #include <cstring> #include <queue> #include <set> #include <map> #include <stack> #include <cstdlib> #includ
阅读全文
posted @ 2016-05-04 16:12 shuguangzw
阅读(154)
评论(0)
推荐(0)
FZU2236 第十四个目标 dp+树状数组优化
摘要: 分析:这种题烂大街,n^2,然后数据结构优化下到nlogn,离散化 #include <cstdio> #include <cstring> #include <queue> #include <set> #include <map> #include <stack> #include <cstdl
阅读全文
posted @ 2016-05-04 15:35 shuguangzw
阅读(199)
评论(0)
推荐(0)
FZU2234 牧场物语 DP
摘要: 题意:先去再回,不能吃重复的,获取最大值 分析:等价于两个人同时去,不能吃重复的 定义dp[i][j][k]表示从起点走k步,第一个人的横坐标是i,第二个人的横坐标是j的最最大值 这个题和bc上一个回文串的题是一样的 #include <cstdio> #include <cstring> #inc
阅读全文
posted @ 2016-05-04 14:58 shuguangzw
阅读(223)
评论(0)
推荐(0)
上一页
1
···
10
11
12
13
14
15
16
17
18
···
30
下一页
公告