L - Ch’s gift HDU - 6162】的更多相关文章

Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2534    Accepted Submission(s): 887 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6162 Problem Description Mr. Cui is working off-campu…
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1354    Accepted Submission(s): 496 Problem Description Mr. Cui is working off-campus and he misses his girl friend very much. After a w…
/* HDU 6162 - Ch’s gift [ LCA,线段树 ] | 2017 ZJUT Multi-University Training 9 题意: N节点的树,Q组询问 每次询问s,t两节点之间的路径上点权值在[a,b]之间的点权总和 分析: 求出每个询问的LCA,然后离线 按dfs顺序更新树状数组,即某点处树状数组中存的值为其所有祖先节点的值 每个点处对答案的贡献为: 当其为第 i 个 lca 时, ans[i] -= 2 * query(a,b) , 再特判该节点 当其为第 i…
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 662    Accepted Submission(s): 229 Problem Description Mr. Cui is working off-campus and he misses his girl friend very much. After a wh…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6162 题目: Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 526    Accepted Submission(s): 177 Problem Description Mr. Cui is working of…
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Mr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing and turning, he decides to get to his…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6162 题意:给出一棵树的链接方法,每个点都有一个数字,询问U->V节点经过所有路径中l < = x < = r的数字和 解法:主席树维护区间和,树剖查询,复杂度nloglog. 代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5+5; const int maxm = 40*maxn; ty…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6162 [算法] 离线树剖 我们知道,u到v路径上权值为[A,B]的数的和 = u到v路径上权值小于等于B的数的和 - u到v路径上权值小于等于(A-1)的数的和 不妨将询问拆开,离线计算答案即可 [代码] #include<bits/stdc++.h> using namespace std; ; int i,n,m,u,v,now,timer,tot,cnt; long long l,r;…
Mr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing and turning, he decides to get to his girl friend's city and of course, with well-chosen gifts. He knows neither too low the price could a gift be sinc…
题意: 已知树上的每个节点的值和节点之间的关系建成了一棵树,现在查询节点u到节点v的最短路径上的节点值在l到r之间的节点值的和. 思路: 用树链剖分将树映射到线段树上,线段树上维护3个值,max,min和sum即可. 接下来就是一个简单的线段树上的查询. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<vector> #inclu…