[hdu3966]Aragorn's Story】的更多相关文章

传送门 题目描述 Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps out of his kingdom and M edges connect them…
AC通道:http://acm.hdu.edu.cn/showproblem.php?pid=3966 [题目大意] 一棵树上每个点有权值,每次支持三种操作:给[a,b]路径上的所有节点的权值加上k,给[a,b]路径上的所有节点的权值减去k,以及询问a的权值. [分析] 这是一道树链剖分模板题. 树链剖分,就是将树化成了许多链,将这些链用数据结构保存起来,再去维护这个数据结构. 假设给的树就是一条链,这道题当然很好办:直接将链用线段树存了,因为[a,b]的路径在线段树上也是连续的一段,那么修改一…
题目传送门 题目大意: 有n个兵营形成一棵树,给出q次操作,每一次操作可以使两个兵营之间的所有兵营的人数增加或者减少同一个数目,每次查询输出某一个兵营的人数. 思路: 树链剖分模板题,讲一下树链剖分过程的理解. 第一步,dfs,记录每个节点的父节点,子节点数目,重子节点,树的深度. 第二步,dfs,处理出dfs序和轻重链的起点,重链形成一条,轻链的起点就是本身,处理dfs序的时候先处理重链的dfs序. 修改,利用树状数组(或者线段树),个人认为这是最难的地方. inline void chang…
题意:给一棵树,并给定各个点权的值,然后有3种操作: I C1 C2 K: 把C1与C2的路径上的所有点权值加上K D C1 C2 K:把C1与C2的路径上的所有点权值减去K Q C:查询节点编号为C的权值 /* 要手动扩栈. */ #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<iostream> #include<cstring>…
题意:给一棵树,并给定各个点权的值,然后有3种操作:I C1 C2 K: 把C1与C2的路径上的所有点权值加上KD C1 C2 K:把C1与C2的路径上的所有点权值减去KQ C:查询节点编号为C的权值 裸裸的树剖 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<cmath> usin…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7495    Accepted Submission(s): 1967 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lor…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1321    Accepted Submission(s): 344 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord…
HDU 3966 Aragorn's Story 先把树剖成链,然后用树状数组维护: 讲真,研究了好久,还是没明白 树状数组这样实现"区间更新+单点查询"的原理... 神奇... #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #inc…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3494    Accepted Submission(s): 973 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord…
题目:Aragorn's Story 题意:给一棵树,并给定各个点权的值,然后有3种操作: I C1 C2 K: 把C1与C2的路径上的所有点权值加上K D C1 C2 K:把C1与C2的路径上的所有点权值减去K Q C:查询节点编号为C的权值 分析:典型的树链剖分题目,先进行剖分,然后用线段树去维护即可,注意HDU的OJ采用Windows系统,容易爆栈,所以在代码 前面加上:#pragma comment(linker, "/STACK:1024000000,1024000000")…
pid=3966" target="_blank" style="">题目链接:hdu 3966 Aragorn's Story 题目大意:给定一个棵树,然后三种操作 Q x:查询节点x的值 I x y w:节点x到y这条路径上全部节点的值添加w D x y w:节点x到y这条路径上全部节点的值降低w 解题思路:树链剖分,用树状数组维护每一个节点的值. #pragma comment(linker, "/STACK:1024000000,1…
HDU Aragorn's Story 题目链接 树抛入门裸题,这题是区间改动单点查询,于是套树状数组就OK了 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; const int N = 50005; inline int lowbit(int x) {return x&(-x);} int dep…
树链拆分+树阵 (进入坑....) Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2934    Accepted Submission(s): 806 Problem Description Our protagonist is the handsome human prince Aragorn c…
HDU - 3966 Aragorn's Story Time Limit: 3000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of ene…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) [Problem Description] Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies w…
Aragorn's Story 来源:http://www.fjutacm.com/Problem.jsp?pid=2710来源:http://acm.hdu.edu.cn/showproblem.php?pid=3966 这题就是一个模板题,模板调过了就可以过 #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include&l…
Aragorn's Story Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/148/E Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10483    Accepted Submission(s): 2757 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lor…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10510    Accepted Submission(s): 2766 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lor…
题目链接: Hdu 3966 Aragorn's Story 题目描述: 给出一个树,每个节点都有一个权值,有三种操作: 1:( I, i, j, x ) 从i到j的路径上经过的节点全部都加上x: 2:( D, i, j, x ) 从i到j的路径上经过的节点全部都减去x: 3:(Q, x) 查询节点x的权值为多少? 解题思路: 可以用树链剖分对节点进行hash,然后用线段树维护(修改,查询),数据范围比较大,要对线段树进行区间更新 #include <cstdio> #include <…
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15842 Accepted Submission(s): 4159 Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord of…
Aragorn's Story Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps out of his kingdom and M…
A - Aragorn's Story 直接套 线段树+树剖 板子 代码: // Created by CAD on 2019/8/12. #include <bits/stdc++.h> #define lson (p<<1) #define rson (p<<1|1) using namespace std; using ll=long long; const int maxn=5e4+5; ll d[maxn<<2],laz[maxn<<2…
HDU3669 Aragorn's Story 树链剖分 点权 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3966 题意: n个点的,m条边,每个点都 有点权 修改 从u->v上所有点的点权 查询单点点权 题解: 树链剖分裸题 树链剖分就是将树分割为多条边,然后利用数据结构来维护这些链的一个技巧 重儿子:父亲节点的所有儿子中子树结点数目最多( size*siz**e* 最大)的结点: 轻儿子:父亲节点中除了重儿子以外的儿子: 重边:父亲结点和重儿…
Link: http://acm.hdu.edu.cn/showproblem.php?pid=3966 这题注意要手动扩栈. 这题我交g++无限RE,即使手动扩栈了,但交C++就过了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <cstring> #include <iostream> #include <algorit…
题意:给一棵树,并给定各个点权的值,然后有3种操作:I C1 C2 K: 把C1与C2的路径上的所有点权值加上KD C1 C2 K:把C1与C2的路径上的所有点权值减去KQ C:查询节点编号为C的权值思路:先树链剖分,然后用线段树维护一下 模板题,具体细节看代码 + ; ; int n, m, p; //线段树部分 int add_value, qL, qR; int addv[maxnode]; void update(int o, int L, int R) { if (qL <= L &…
我无限Runtime Error(ACCESS_VIOLATION).不知道怎么搞得/(ㄒoㄒ)/~~ #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define for1(i,a,n) for(int i=(a);i<…
给你n个点,m条边,p次操作.n个点相连后是一棵树.每次操作可以是x 到 y 增加 z,或者减z,或者问当前点的值是多少. 可以将树分成链,每个点在线段树上都有自己的点,然后线段树成段更新一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<queue> #include<stack> #include<cmath> #include<cstdio> #i…
题意:给出一颗树形图,有三种操作,I:在u到v的路径上的每个点的权值+d,D:在u到v的路径上的每个点的权值都-d,Q询问u点的权值 #pragma comment(linker, "/STACK:1024000000,1024000000") #include"stdio.h" #include"string.h" #include"stdlib.h" #include"algorithm" #inclu…
http://acm.hdu.edu.cn/showproblem.php?pid=3966 题意:有n个点n-1条边,每个点有一个权值,有两种操作:询问一个点上权值是多少和修改u到v这条链上的权值. 思路:树链剖分.学习地址:http://blog.sina.com.cn/s/blog_7a1746820100wp67.html   http://blog.csdn.net/acdreamers/article/details/10591443 #include <cstdio> #incl…