会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
starve_to_death
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
30
31
32
33
34
35
下一页
2019年5月13日
离散化二维坐标
摘要: 二维坐标离散化 离散化的思想就是将分布大却数量少(即稀疏)的数据进行集中化的处理,这样可以有利于程序的空间与时间,能减少遍历次数与空间储存。 思想理解起来其实道理很简单,如坐标(3,2000),(10005,31),(10006,5)离散至新图,先看x坐标,3个点有3,10005,10006,离散后
阅读全文
posted @ 2019-05-13 09:28 starve_to_death
阅读(493)
评论(0)
推荐(0)
2019年5月10日
P2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 inline int read(){ 4 int sum=0,x=1; 5 char ch=getchar(); 6 while(ch<'0'||ch>'9'){ 7 if(ch=='-') 8 x
阅读全文
posted @ 2019-05-10 17:20 starve_to_death
阅读(106)
评论(0)
推荐(0)
2019年5月9日
树链剖分板子
摘要: 1 const int N = 1e5 + 5; 2 vector<int> g[N]; 3 int fa[N], dp[N], sz[N], son[N], top[N], dfn[N], to[N], cnt = 0, n; 4 void dfs1(int u, int o) { 5 fa[u]
阅读全文
posted @ 2019-05-09 18:18 starve_to_death
阅读(144)
评论(0)
推荐(0)
P2486 [SDOI2011]染色 区间合并+树链剖分(加深对线段树的理解)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int M=3e5+5; 4 struct node{ 5 int l,r,cnt,lazy; 6 node(int l1=0,int r1=0,int cnt1=0,int lazy1
阅读全文
posted @ 2019-05-09 18:15 starve_to_death
阅读(121)
评论(0)
推荐(0)
2019年5月6日
hdu 1754
摘要: 在写的时候加了判断询问位置先后的swap结果wa了快十次了,不知道为什么; http://acm.hdu.edu.cn/showproblem.php?pid=1754
阅读全文
posted @ 2019-05-06 21:04 starve_to_death
阅读(126)
评论(0)
推荐(0)
poj2777 Count Color
摘要: 不开longlong见祖宗 题目没说操作中的a,b大小要注意 接着就是状压+线段树 http://poj.org/problem?id=2777
阅读全文
posted @ 2019-05-06 18:24 starve_to_death
阅读(122)
评论(0)
推荐(0)
板子(含二维线段树)
摘要: 区间修改&&单点查询(树状数组) #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> #include<list> #include<ma
阅读全文
posted @ 2019-05-06 16:27 starve_to_death
阅读(176)
评论(0)
推荐(0)
2019年5月5日
树的直径
摘要: 树的直径: 利用了树的直径的一个性质:距某个点最远的叶子节点一定是树的某一条直径的端点。 先从任意一顶点a出发,bfs找到离它最远的一个叶子顶点b,然后再从b出发bfs找到离b最远的顶点c,那么b和c之间的距离就是树的直径。 用dfs也可以。 http://poj.org/problem?id=19
阅读全文
posted @ 2019-05-05 23:49 starve_to_death
阅读(154)
评论(0)
推荐(0)
2019年5月4日
hdu2876 Connections between cities(LCA倍增)
摘要: 图不一定联通,所以用并查集找各个联通块的祖先分别建图,之后就和LCA的步骤差不多了
阅读全文
posted @ 2019-05-04 17:34 starve_to_death
阅读(129)
评论(0)
推荐(0)
hdu 2586 How far away ?(LCA模板)(倍增法)
摘要: 在dfs的过程中维护三个数组: deep[i],表示i点在树中的深度; grand[x][i],表示x的第2^i个祖先的节点编号; dis[x][i],表示x到它2^i祖 先的距离。
阅读全文
posted @ 2019-05-04 14:45 starve_to_death
阅读(163)
评论(0)
推荐(0)
上一页
1
···
30
31
32
33
34
35
下一页
公告