题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5405 题意: 给你一棵n个节点的树,有点权.        要求支持两种操作: 操作1:更改某个节点的权值. 操作2:给定u,v, 求 Σw[i][j]   i , j 为任意两点且i到j的路径与u到v的路径相交. 解法: 这是一个大树剖题. 容易发现对于一个询问,答案为总点权和的平方 减去 去掉u--v这条链后各个子树的点权和的平方的和. 开两棵线段树,tag1记录点权和,tag2记录某点的所有轻…
Sometimes Naive Problem Description   Rhason Cheung had a naive problem, and asked Teacher Mai for help. But Teacher Mai thought this problem was too simple, sometimes naive. So she ask you for help. She has a tree with n vertices, numbered from 1 to…
题意:给一棵树,每次给两个节点间的所有节点发放第k种东西,问最后每个节点拿到的最多的东西是哪种. 解法:解决树的路径上的修改查询问题一般用到的是树链剖分+线段树,以前不会写,后来学了一下树链剖分,感觉也不是很难,就是把整个数分成很多链,然后一条重链上的点在线段树中位置是连续的,这样使得更新和查询时更加便利. 这个题目中线段树应该维护的是种类,每次对u-v发放k时,可以让u处+k,v+1处-k,把这些都离线存起来,然后枚举1~n,分别把自己该做的操作都做了,然后统计的时候tree[1].type就…
题目链接:hdu 5029 Relief grain 题目大意:给定一棵树,然后每次操作在uv路径上为每一个节点加入一个数w,最后输出每一个节点个数最多的那个数. 解题思路:由于是在树的路径上做操作,所以基本就是树链剖分了.仅仅只是曾经是用一个数组就可以维护值,这题要用 一个vector数组记录.过程中用线段树维护最大值. #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #i…
Relief grain Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5029 Description The soil is cracking up because of the drought and the rabbit kingdom is facing a serious famine. The RRC(Rabbit Red Cross) organizes…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=4366 [题目大意] 有一个公司,每个员工都有一个上司,所有的人呈树状关系,现在给出每个人的忠诚值和能力值,每次当一个人被辞退的时候,会由能力值大于他的下属中忠诚值最高的去代替他的位置,下属的关系是可传递的,上司的编号一定大于下属.现在给出一些询问,问如果一个人辞退将会由哪个人代替他,所有人的忠诚值都是唯一的. [题解] 现在这道题就相当于是从子树中找出key1值大于子树根节点且key2值最高的子…
HDU 5044 Tree field=problem&key=2014+ACM%2FICPC+Asia+Regional+Shanghai+Online&source=1&searchmode=source" target="_blank" style="">题目链接 就简单的树链剖分,只是坑要加输入外挂,还要手动扩栈 代码: #include <cstdio> #include <cstring>…
Game Time Limit:1500MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5242 Appoint description:  System Crawler  (2015-05-26) Description It is well known that Keima Katsuragi is The Capturing God because of his…
Game Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1376    Accepted Submission(s): 449 Problem Description It is well known that Keima Katsuragi is The Capturing God because of his exceptional…
Tree Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9123   Accepted: 2411 Description You are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edges are numbered 1 through N − 1. Each edge is associated with…