摘要:
二维坐标离散化 离散化的思想就是将分布大却数量少(即稀疏)的数据进行集中化的处理,这样可以有利于程序的空间与时间,能减少遍历次数与空间储存。 思想理解起来其实道理很简单,如坐标(3,2000),(10005,31),(10006,5)离散至新图,先看x坐标,3个点有3,10005,10006,离散后 阅读全文
摘要:
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 阅读全文
摘要:
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] 阅读全文
摘要:
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 阅读全文
摘要:
在写的时候加了判断询问位置先后的swap结果wa了快十次了,不知道为什么; http://acm.hdu.edu.cn/showproblem.php?pid=1754 阅读全文
摘要:
不开longlong见祖宗 题目没说操作中的a,b大小要注意 接着就是状压+线段树 http://poj.org/problem?id=2777 阅读全文
摘要:
区间修改&&单点查询(树状数组) #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> #include<list> #include<ma 阅读全文
摘要:
树的直径: 利用了树的直径的一个性质:距某个点最远的叶子节点一定是树的某一条直径的端点。 先从任意一顶点a出发,bfs找到离它最远的一个叶子顶点b,然后再从b出发bfs找到离b最远的顶点c,那么b和c之间的距离就是树的直径。 用dfs也可以。 http://poj.org/problem?id=19 阅读全文