题目是中文,所以不讲题意 做法顺序如下: 使用先跟遍历,把整棵树平铺到一维平面中 使用自己整的区间更新树状数组模板进行相关操作. http://www.cnblogs.com/rikka/p/7359185.html 放代码如下: #include<bits/stdc++.h> using namespace std; /* *常量MAXN用于设定树状数组的尺寸大小 */ ; class TreeLikeArray { public: /* *数组c1用来储存A[i]-A[i-1]: */ l…
点权树的模板题,另外发现树状数组也是可以区间更新的.. 注意在对链进行操作时方向不要搞错 线段树版本 #include<bits/stdc++.h> using namespace std; #define maxn 50005 #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 ]; int a[maxn],head[maxn],tot; int deep[maxn],fa[maxn],son[maxn],num[max…
To the moonTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88748#problem/I Description To The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG…
https://vjudge.net/problem/POJ-3468 线段树区间更新(lazy数组)模板题 #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<algorithm> #include<cmath> #include<map> #define lson l, m, rt<<1 #define…
主席树带修第k大 https://www.cnblogs.com/Empress/p/4659824.html 讲的非常好的博客 首先按静态第k大建立起一组权值线段树(主席树) 然后现在要将第i个值从a改为b, 由主席树前缀和的性质可知修改第i个值会对T[i]...T[n]棵权值线段树造成相同的影响 如果暴力进行维护必定超时 那么如何优化这种修改? 我们知道动态维护前缀和可以用bit在log时间内完成 那么对于动态维护具有前缀和性质的主席树,我们也可以套上bit来完成 update:将第i个值从…
Turing Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4948    Accepted Submission(s): 1746 Problem Description After inventing Turing Tree, 3xian always felt boring when solving problems a…
51nod 1681 公共祖先 有一个庞大的家族,共n人.已知这n个人的祖辈关系正好形成树形结构(即父亲向儿子连边). 在另一个未知的平行宇宙,这n人的祖辈关系仍然是树形结构,但他们相互之间的关系却完全不同了,原来的祖先可能变成了后代,后代变成的同辈-- 两个人的亲密度定义为在这两个平行宇宙有多少人一直是他们的公共祖先. 整个家族的亲密度定义为任意两个人亲密度的总和. Input 第一行一个数n(1<=n<=100000) 接下来n-1行每行两个数x,y表示在第一个平行宇宙x是y的父亲. 接下…
During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity. To check whether their understanding of properties of hyperspace is…
题意: 有一个n*n的矩阵,初始化全部为0.有2中操作: 1.给一个子矩阵,将这个子矩阵里面所有的0变成1,1变成0:2.询问某点的值 方法一:二维线段树 参考链接: http://blog.csdn.net/xiamiwage/article/details/8030273 思路: 二维线段树,一维线段树的成段更新需要lazy. 引申到二维线段树应该需要一个lazy,一个sublazy,可是这里什么都不用.    奇妙之处在于这题的操作是异或,当某一段区间需要异或操作时候, 不必更新到它所有的…
任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given n segments on a line. There are no ends of some segments th…