BZOJ3531:[SDOI2014]旅行(树链剖分)
Description
S国有N个城市,编号从1到N。城市间用N-1条双向道路连接,满足
从一个城市出发可以到达其它所有城市。每个城市信仰不同的宗教,如飞天面条神教、隐形独角兽教、绝地教都是常见的信仰。为了方便,我们用不同的正整数代表各种宗教,
S国的居民常常旅行。旅行时他们总会走最短路,并且为了避免麻烦,只在信仰和他们相同的城市留宿。当然旅程的终点也是信仰与他相同的城市。S国政府为每个城市标定了不同的旅行评级,旅行者们常会记下途中(包括起点和终点)留宿过的城市的评级总和或最大值。
在S国的历史上常会发生以下几种事件:
”CC x c”:城市x的居民全体改信了c教;
”CW x w”:城市x的评级调整为w;
”QS x y”:一位旅行者从城市x出发,到城市y,并记下了途中留宿过的城市的评级总和;
”QM x y”:一位旅行者从城市x出发,到城市y,并记下了途中留宿过
的城市的评级最大值。
由于年代久远,旅行者记下的数字已经遗失了,但记录开始之前每座城市的信仰与评级,还有事件记录本身是完好的。请根据这些信息,还原旅行者记下的数字。 为了方便,我们认为事件之间的间隔足够长,以致在任意一次旅行中,所有城市的评级和信仰保持不变。
Input
输入的第一行包含整数N,Q依次表示城市数和事件数。
接下来N行,第i+l行两个整数Wi,Ci依次表示记录开始之前,城市i的
评级和信仰。
接下来N-1行每行两个整数x,y表示一条双向道路。
接下来Q行,每行一个操作,格式如上所述。
Output
对每个QS和QM事件,输出一行,表示旅行者记下的数字。
Sample Input
3 1
2 3
1 2
3 3
5 1
1 2
1 3
3 4
3 5
QS 1 5
CC 3 1
QS 1 5
CW 3 3
QS 1 5
QM 2 4
Sample Output
9
11
3
HINT
N,Q < =10^5 , C < =10^5
数据保证对所有QS和QM事件,起点和终点城市的信仰相同;在任意时
刻,城市的评级总是不大于10^4的正整数,且宗教值不大于C。
Solution
因为板子是抄的另一个题的所以细节没改全WA了两次才过QAQ
对于这个题我们第一反应就是:诶这不是裸的树链剖分……
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4SmERXhpZgAATU0AKgAAA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9w2IvlwlnIekwkUuxEcPRE8uiqv6Obv+8wfjP8tMwbRSTamYAom1LFrUwFzdiqomOLZ5Kvb/7V62TikTDF2W+8acqtDAcZbBdEXipIqoWnmXenCrAmj8nd4FdUkwv5h/kqVptSgFyYsiVOcQnHGo4MYgouEORkXauJIvDFPLtWhoW6YVxYYe9KjsjzK81NfcR1U8OiryJ56/Qi99MtSoE68W6Q9fH5AxVNCfZQC3eq8EHVUXdEqJ7chSrrNuemXaQ6syZuwNgtXmBFDUCJcegV0ThxTz76ZKlUAJsKJOuKSpFrEmI+quOnGyN4tMUFB0yIU7fh0rqzxWUn3F2HFOHHcBtsFRjc6kmWqoKonrJx0o7UqBYg2gGZwtNRXAFuUR70kXoQR716tS0X4qMQGzCbcyICQTkCoqqdSbptOH8Fq9XtEe1KlSqr/9kA" alt="" />
等等好像不太对
这个每次询问只统计链上和起点终点同类的人
那样的话我们对于每一种搞一个链剖就好……
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAC2AI4DASIAAhEBAxEB/8QAHQABAAMBAQEBAQEAAAAAAAAAAAUGBwgDBAkCAf/EAEYQAAEDBAECAwUGAgUICwAAAAECAwQABQYREgchEzFBCBQiUWEVFiMycZFSgUJiobHSFzNDV4KUwdMYNDZEY2d1srTC5P/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDqmlKrl+yWNY7zYLdKZfUu8SFxmnEAcW1pQV/Fs77gEDW6Cx0qkZPmcKJNgWmKXpEi7xprjEmKtKm2fd29qKlA7HcgDW+/nqs56S9W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89DdaapQSkqUQEgbJPpVZwrD4WI2t6NBcfkTJLhflzpJ5vSXj5rWfX6DyFVeZA6soaXCYuuHzGHE+H76/GkMPJB7FXhpKkE63obA3qg9/Z1aLXRjGSVlxbjTrylqOyVLecWdn9VGvvm45OnZ69kF0cZNtt1vXHtkdCiVBxwfjPL7dlaAQNE9t/Op3CLE3i+JWixtO+KIEZDHicePMgd1a9NnZ1UxJQXY7rYIBWkpBP1FBiGDNWqL7PeOZJco4VJsFtkzIjgUUqQspcSQNEb5A60exOvlWidIra5Z+mWLwXm/Cfat7JcQfNK1JClA/XZNUy3dM7w9g2F4pdpUJNmt58W8MtlS1S1IXzaaTsAeHyJKie/wjVbGAANDsKDN+gf8A2Mn/APrVw/8AkLrSap3TPHJeMWCTBnLZW65cJUoFpRICHHlLSO4HfRG6uNApSlApSlApSlApSlApSlApSlApSlApSlApSlB//9kA" alt="" />
等等好像还是不太对
空间开不开啊QAQ
那咱就线段树动态开点好了。
分析一波复杂度:需要动态开点的只有我代码里的update函数,每次一update最差情况会新增log个节点
那样的话空间就是NlogN的了。
搞定
Code
#include<iostream>
#include<cstring>
#include<cstdio>
#define N (2000000+100)
using namespace std; struct segt{int val,add,max,ls,rs;}Segt[N<<],refun[N];
struct node{int to,next;}edge[N<<];
int n,m,a[N],u,v,l,ans,w[N],c[N],Root[N],x,y;
int head[N],num_edge;
int Father[N],Depth[N],Son[N],Sum[N];
int T_num[N],Tree[N],Top[N],dfs_num,segt_num;
char opt[]; void add(int u,int v)
{
edge[++num_edge].to=v;
edge[num_edge].next=head[u];
head[u]=num_edge;
} void Dfs1(int x)
{
Sum[x]=;
Depth[x]=Depth[Father[x]]+;
for (int i=head[x]; i; i=edge[i].next)
if (edge[i].to!=Father[x])
{
Father[edge[i].to]=x;
Dfs1(edge[i].to);
Sum[x]+=Sum[edge[i].to];
if (!Son[x] || Sum[Son[x]]<Sum[edge[i].to])
Son[x]=edge[i].to;
}
} void Dfs2(int x,int pre)
{
T_num[x]=++dfs_num;
Tree[dfs_num]=a[x];
Top[x]=pre;
if (Son[x]) Dfs2(Son[x],pre);
for (int i=head[x]; i; i=edge[i].next)
if (edge[i].to!=Father[x] && edge[i].to!=Son[x])
Dfs2(edge[i].to,edge[i].to);
} void Pushup(int now)
{
Segt[now].val=Segt[Segt[now].ls].val+Segt[Segt[now].rs].val;
Segt[now].max=max(Segt[Segt[now].ls].max,Segt[Segt[now].rs].max);
} void Update(int &now,int l,int r,int x,int k)
{
if (!now) now=++segt_num;
if (l==r)
{
Segt[now].val=k;
Segt[now].max=k;
return;
}
int mid=(l+r)>>;
if (x<=mid) Update(Segt[now].ls,l,mid,x,k);
else Update(Segt[now].rs,mid+,r,x,k);
Pushup(now);
} int Query_Sum(int now,int l,int r,int l1,int r1)
{
if (now==) return ;
if (l>r1 || r<l1) return ;
if (l1<=l && r<=r1)
return Segt[now].val;
int mid=(l+r)>>;
if (r1<=mid) return Query_Sum(Segt[now].ls,l,mid,l1,r1);
if (l1>=mid+) return Query_Sum(Segt[now].rs,mid+,r,l1,r1);
return Query_Sum(Segt[now].ls,l,mid,l1,r1)+Query_Sum(Segt[now].rs,mid+,r,l1,r1);
} int Query_Max(int now,int l,int r,int l1,int r1)
{
if (now==) return -;
if (l>r1 || r<l1) return -;
if (l1<=l && r<=r1)
return Segt[now].max;
int mid=(l+r)>>;
if (r1<=mid) return Query_Max(Segt[now].ls,l,mid,l1,r1);
if (l1>=mid+) return Query_Max(Segt[now].rs,mid+,r,l1,r1);
return max(Query_Max(Segt[now].ls,l,mid,l1,r1),Query_Max(Segt[now].rs,mid+,r,l1,r1));
} int Ask_Sum(int x,int y)
{
int fx=Top[x],fy=Top[y],r=c[x],ans=;
while (fx!=fy)
{
if (Depth[fx]<Depth[fy])
swap(x,y),swap(fx,fy);
ans+=Query_Sum(Root[r],,n,T_num[fx],T_num[x]);
x=Father[fx],fx=Top[x];
}
if (Depth[x]<Depth[y]) swap(x,y);
ans+=Query_Sum(Root[r],,n,T_num[y],T_num[x]);
return ans;
} int Ask_Max(int x,int y)
{
int fx=Top[x],fy=Top[y],r=c[x],ans=;
while (fx!=fy)
{
if (Depth[fx]<Depth[fy])
swap(x,y),swap(fx,fy);
ans=max(ans,Query_Max(Root[r],,n,T_num[fx],T_num[x]));
x=Father[fx],fx=Top[x];
}
if (Depth[x]<Depth[y]) swap(x,y);
ans=max(ans,Query_Max(Root[r],,n,T_num[y],T_num[x]));
return ans;
} int main()
{
scanf("%d%d",&n,&m);
for (int i=; i<=n; ++i)
scanf("%d%d",&w[i],&c[i]);
for (int i=; i<=n-; ++i)
{
scanf("%d%d",&u,&v);
add(u,v); add(v,u);
}
Dfs1(); Dfs2(,);
for (int i=; i<=n; ++i)
Update(Root[c[i]],,n,T_num[i],w[i]); for (int i=; i<=m; ++i)
{
scanf("%s%d%d",opt,&x,&y);
if (opt[]=='C' && opt[]=='C')
{
Update(Root[c[x]],,n,T_num[x],);
c[x]=y;
Update(Root[c[x]],,n,T_num[x],w[x]);
}
if (opt[]=='C' && opt[]=='W')
{
w[x]=y;
Update(Root[c[x]],,n,T_num[x],w[x]);
}
if (opt[]=='Q' && opt[]=='S')
printf("%d\n",Ask_Sum(x,y));
if (opt[]=='Q' && opt[]=='M')
printf("%d\n",Ask_Max(x,y));
}
}
BZOJ3531:[SDOI2014]旅行(树链剖分)的更多相关文章
- BZOJ3531 SDOI2014 旅行 - 树链剖分,主席树
题意:给定一棵树,树上每个点有权值和类型.支持:修改某个点的类型:修改某个点的权值:询问某条链上某个类型的点的和/最大值.点数/类型数/询问数<=100000. 分析: 树链剖分,对每个类型的点 ...
- BZOJ3531 [Sdoi2014]旅行 树链剖分 线段树
原文链接:http://www.cnblogs.com/zhouzhendong/p/8080189.html 题目传送门 - BZOJ3531 题意概括 一棵树,n个节点,每一个节点两个值,一个颜色 ...
- BZOJ3531[Sdoi2014]旅行——树链剖分+线段树
题目描述 S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神教.隐形独角兽教.绝地教都是常见的信仰.为了方便,我们 ...
- BZOJ 3531: [Sdoi2014]旅行 [树链剖分]
3531: [Sdoi2014]旅行 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 1685 Solved: 751[Submit][Status] ...
- P3313 [SDOI2014]旅行——树链剖分+线段树(动态开点?)
P3313 [SDOI2014]旅行 一棵树,其中的点分类,点有权值,在一条链上找到一类点中的最大值或总和: 树链剖分把树变成链: 把每个宗教单开一个线段树,维护区间总和和最大值: 宗教很多,需要动态 ...
- BZOJ 3531 [Sdoi2014]旅行 树链剖分+动态开点线段树
题意 S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神教.隐形独角兽教.绝地教都是常见的信仰. 为了方便,我们用 ...
- 洛谷P3313 [SDOI2014]旅行(树链剖分 动态开节点线段树)
题意 题目链接 Sol 树链剖分板子 + 动态开节点线段树板子 #include<bits/stdc++.h> #define Pair pair<int, int> #def ...
- BZOJ 3531 SDOI2014 旅行 树链剖分+线段树动态开点
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3531 题意概述: 给出一棵N个点的树,树上的每个结点有一个颜色和权值,支持以下四种操作: ...
- 【BZOJ3531】[Sdoi2014]旅行 树链剖分+动态开点线段树
[BZOJ3531][Sdoi2014]旅行 Description S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天 ...
随机推荐
- 2.3 if switch for等流程控制
if条件中可以写多个语句,语句的作用域仅限于if,不可在if之外的地方使用 package main import ( "fmt" "io/ioutil" ) ...
- ionic 开发当中,有一些常用的方法。
在开发项目的时候,有些常用的功能封装到一个类里. 以后要用的话,直接导入过来就可以用了,有一些方法是从网站复制过来的,有些方法是网上复制过来,然后自己修改了一下,标记一下吧! /** * ...
- 使用urllib和http.cookiejar获取python老男孩学员成绩
打开http://crm.oldboyedu.com/crm/grade/single/ 鼠标右键查看源代码,可以看到我们需要post的name.如下: 这里需要在post试提交token和searc ...
- 深入理解JavaScript系列(22):S.O.L.I.D五大原则之依赖倒置原则DIP
前言 本章我们要讲解的是S.O.L.I.D五大原则JavaScript语言实现的第5篇,依赖倒置原则LSP(The Dependency Inversion Principle ). 英文原文:htt ...
- [转](.NET Core C#) AES Encryption
本文转自:https://www.example-code.com/dotnet-core/crypt2_aes.asp Chilkat.Crypt2 crypt = new Chilkat.Cryp ...
- BulletedList项目控件基础CSS基础
呈现形态&控件语法: <ul id=“...”> <li></li> . <li></li> . <li></li ...
- js.css嵌入dll
处理请求,返回 public ActionResult Get() { //传递一个部分名称 var n = Request["n"]; n = n.Replace('/', '. ...
- [Linq To Sql]解决join时的Collation冲突
背景 现在两表 A:
- Java日志框架解析及实战分析
转载自: https://zhuanlan.zhihu.com/p/24272450 https://zhuanlan.zhihu.com/p/24275518 作为Java程序员,幸运的是,Java ...
- Maven之依赖关系
在maven的管理体系中,各个项目组成了一个复杂的关系网,但是每个项目都是平等的,是个没有贵贱高低,众生平等的世界,全球每个项目从理论上来说都可以相互依赖.就是说,你跟开发Spring的大牛们平起平坐 ...