HDU-4729 树链剖分+主席树

[GDOI2016][树链剖分+主席树]疯狂动物城 题面: Description Nick 是只在动物城以坑蒙拐骗为生的狐狸,儿时受到偏见的伤害,放弃了自己的理想。他被兔子 Judy 设下圈套,被迫与她合作查案,而卷入意想不到的阴谋,历尽艰险后成为搭档。他们识破了绵羊副市长 Bellwether 的计划,发现是 Bellwether 陷害食肉动物,用毒药让食肉动物发狂。Bellwether 被抓到了监狱里面, Nick 和 Judy 过上了一... 阅读详情

An Easy Problem for Elfness

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1207    Accepted Submission(s): 249


Problem Description
Pfctgeorge is totally a tall rich and handsome guy. He plans to build a huge water transmission network that covers the whole southwest China. To save the fund, there will be exactly one path between two cities.

Since the water every city provides and costs every day is different, he needs to transfer water from one particular city to another as much as possible in the next few days. However the pipes which connect the cities have a limited capacity for transmission. (Which means the water that transfer though the pipe should not exceed a particular amount) So he has to know the maximum water that the network can transfer in the next few days.

He thought it's a maximum flow problem, so he invites an expert in this field, Elfness (Also known as Xinhang senior sister) to help him figure it out.

Unlike Pfctgeorge, Elfness quickly finds that this problem is much easier than a normal maximum flow problem, and is willing to help Pfctgeorge.

"Oh well, this problem is not a tough one. We can ..."

Abruptly, Pfctgeorge's iPhone rings, and ... the ringtone is Mo Di Da Biao Ke.

"You can make that? Excellent! "Pfctgeorge hangs up his iPhone, and turns to Elfness.

"Here's good news for you. A construction team told me that every pipe's capacity can be extended for one day. And the price for extending one unit capacity varies from day to day. "

"Eh well, that's a good news for you, not me. Now it's rather like a minimum cost ow problem, right? But it's still not a tough one, let me have a think. "

After a few seconds' thought, Elfness comes up with a simple solution.

"Ok, we can solve it like... "

Abruptly, here comes Mo Di Da Biao Ke again.

"Seriously? You can build new pipes? Thank you very much. "

"OK, my dear Elfness, we got more good news. Another construction team said they can build one or more pipes between any two cities and their pipes are exactly like the original ones except that they only work for one day. And the capacity of the new pipes is only one, but they can be extended, too. Of course, their price to build a single pipe also varies in days. "

"You mean the new pipes can be extended too? Wow, things are getting more interesting. Give me a few minutes. "

Elfness takes out his new ultrabook which is awarded in VK cup and does some basic calculation.

"I get it. The problem can be solved ..."

Mo Di Da Biao Ke again, but this time it's from Elfness's phone.

"As you see, I have to go out. But I know someone else who can also solve this; I'll recommend this guy for you. "

And of course, that poor guy is YOU. Help Pfctgeorge solve his problem, and then the favorability about you from Elfness will raise a lot.
 

Input
The first line has a number T (T <= 10) , indicating the number of test cases.

The first line of each test case is two integers N (1 <= N <= 100000) and M (1 <= M <= 100000), indicating the number of the city that the original network connects and the number of days when Pfctgeorge needs to know about the maximum water transmissions. Then next N - 1 lines each describe a pipe that connects two cities. The format will be like U, V , cap (1 <= U, V <= N and 0 <= cap < 10000), which means the ids of the two cities the pipe connects and the transmission limit of the pipe. As is said in description, the network that the cities and pipes form is a tree (an undirected acyclic graph).

Then next M lines of the test case describe the information about the next few days. The format is like  S, T, K, A, B(0 <= K <= 2^31 - 1, 1 <= A, B <= 2^31 - 1). S means the source of the water while T means the sink. K means the total budget in the day. A means the cost for a construction team to build a new pipe and B means the cost for a construction team to extend the capacity of a pipe.

I am glad to list the information of building a new pipe and extending the capacity.

1. Pfctgeorge can build a new pipe between any two cities, no matter they have been directly connected or not. Pfctgeorge can build more than one new pipe between any two cities.
2. The capacity of the pipe that was newly built is  one.
3. Pfctgeorge can extend the capacity of any existed pipe including the newly built one and the original one.
4. Each time you extend the capacity of one pipe, the capacity of that pipe increases one.
5. The cost of building a new pipe is A and the cost of extending a pipe is B.
6. You can take any constructions in any times and the only limit is to make sure the total costs not exceed the budget.
7.  All the work that construction team does only lasts one single day.
 

Output
For every case, you should output "Case #t:" at first, without quotes. The t is the case number starting from 1.
Then for each day, output the maximum water Pfctgeorge can transfer from S and T with a budget of K.
 

Sample Input
  
2 5 1 1 2 2 1 3 5 2 4 1 4 5 2 1 5 3 3 2 5 5 1 2 10 2 3 2 3 4 7 2 5 7 1 5 0 1 3 1 3 0 2 3 1 5 3 2 3 1 2 7 3 1 1 3 2 3 1
 

Sample Output
  
Case #1: 2 Case #2: 7 2 8 17 4
Hint
In the first sample case, you can extend the capacity of the pipe which connects city2 and city4 by one, or just build a new pipe between city2 and city4.
 

Source

2013 ACM/ICPC Asia Regional Chengdu Online


题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=4729


题目大意:

给出一棵带边权的树,m次询问,每次询问有两种操作,加一条单位边花费为A,将某条边流量扩展一单位花费为B,求预算为K的情况下流量的最大值。


解题思路:

首先做一次树链剖分,用RMQ求一下S到T路径上的最小值,然后考虑扩展流量的问题。

对于a<=b的情况,只要在S与T之间建边,然后不断扩展其流量即可。

对于a>b的情况,可以在S与T间建边,最多扩容(k-a)/b+1;也可以在原有路径上扩容,这里二分扩容量,需要用到主席树来统计路径上边权小于该值的边的数量与权值之和。最后取两者中的小者即可。

需要注意在S与T之间建边时需要判断k>=a,另外数据比较弱没有卡int,代码后面附上两组数据供参考。


AC代码:

import java.io.*;
import java.util.*;

public class Main {
	static StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException    
	{  
	    in.nextToken();    
	    return (int)in.nval;     
	}
	static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
	static int T,n,m,ee,a,b,c,ct,max,k;
	static int ss,tt,pp,aa,bb,sz;
	static long qq,isum,nsum,ans,l,r,mid,res;
	static int[] head=new int[100005];
	static int[] edge=new int[200005];
	static int[] next=new int[200005];
	static int[] cost=new int[200005];
	static int[] fa=new int[100005];
	static int[] id=new int[100005];
	static int[] ww=new int[100005];
	static int[] pos=new int[100005];
	static int[] top=new int[100005];
	static int[] dep=new int[100005];
	static int[] son=new int[100005];
	static int[] size=new int[100005];
	static int[][] min=new int[18][100005];
	static int[] rt=new int[100005];
	static int[] ls=new int[1500005];
	static int[] rs=new int[1500005];
	static int[] cnt=new int[1500005];
	static int[] sum=new int[1500005];
	static void build(int l,int r,int k)
	{
		cnt[k]=0;sum[k]=0;
		if(l==r) return;
		int mid=(l+r)/2;
		ls[k]=++sz;build(l,mid,ls[k]);
		rs[k]=++sz;build(mid+1,r,rs[k]);
	}
	static void updata(int a,int b,int x,int l,int r)
	{
		cnt[a]=cnt[b]+1;
		sum[a]=sum[b]+x;
		if(l==r) return;
		int mid=(l+r)/2;
		if(x<=mid)
		{
			rs[a]=rs[b];ls[a]=++sz;
			updata(ls[a],ls[b],x,l,mid);
		}
		else
		{
			ls[a]=ls[b];rs[a]=++sz;
			updata(rs[a],rs[b],x,mid+1,r);
		}
	}
	static void query(int a,int b,long x,int l,int r)
	{
		if(x>=r)
		{
			nsum+=cnt[b]-cnt[a];
			isum+=sum[b]-sum[a];
			return;
		}
		int mid=(l+r)/2;
		query(ls[a],ls[b],x,l,mid);
		if(x>mid) query(rs[a],rs[b],x,mid+1,r);
	}
	static void init()
	{
		for(int i=1;i<=n;i++)
			min[0][id[i]]=ww[i];
		for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i+(1<<j)-1<=n;i++)
			min[j][i]=Math.min(min[j-1][i],min[j-1][i+(1<<(j-1))]);
	}
	static int min(int l,int r)
	{
		int k=0,res;
		while((1<<(k+1))<r-l+1) k++;
		res=Math.min(min[k][l],min[k][r-(1<<k)+1]);
		return res;
	}
	static void add(int a,int b,int c)
	{
		edge[ee]=b;next[ee]=head[a];
		cost[ee]=c;head[a]=ee++;
	}
	static void dfs(int u,int f,int d)
	{
		size[u]=1;dep[u]=d;
		son[u]=-1;fa[u]=f;
		int v;
		for(int i=head[u];i!=-1;i=next[i])
		{
			v=edge[i];
			if(v==f) continue;
			dfs(v,u,d+1);
			size[u]+=size[v];
			ww[v]=cost[i];
			max=Math.max(max,ww[v]);
			if(son[u]==-1||size[son[u]]<size[v])
				son[u]=v;
		}
	}
	static void dfs2(int u,int f,int t)
	{
		id[u]=++ct;top[u]=t;
		pos[ct]=u;
		if(son[u]!=-1) dfs2(son[u],u,t);
		int v;
		for(int i=head[u];i!=-1;i=next[i])
		{
			v=edge[i];
			if(v==f||v==son[u]) continue;
			dfs2(v,u,v);
		}
	}
	static void prepare()
	{
		max=0;dfs(1,0,1);
		ct=0;dfs2(1,0,1);
		init();sz=0;
		rt[0]=++sz;build(0,max,rt[0]);
		for(int i=1;i<=n;i++)
		{
			rt[i]=++sz;
			updata(rt[i],rt[i-1],ww[pos[i]],0,max);
		}
	}
	static int getmin(int u,int v)
	{
		int ans=10000000;
		while(top[u]!=top[v])
		{
			a=top[u];b=top[v];
			if(dep[a]<dep[b])
			{
				c=u;u=v;v=c;
				c=a;a=b;b=c;
			}
			ans=Math.min(ans,min(id[top[u]],id[u]));
			u=fa[top[u]];
		}
		if(u!=v)
		{
			if(dep[u]>dep[v]) { c=u;u=v;v=c;}
			ans=Math.min(ans,min(id[son[u]],id[v]));
		}
		return ans;
	}
	static long get(int u,int v,long x)
	{
		nsum=isum=0;
		while(top[u]!=top[v])
		{
			a=top[u];b=top[v];
			if(dep[a]<dep[b])
			{
				c=u;u=v;v=c;
				c=a;a=b;b=c;
			}
			query(rt[id[top[u]]-1],rt[id[u]],x,0,max);
			u=fa[top[u]];
		}
		if(u!=v)
		{
			if(dep[u]>dep[v]) { c=u;u=v;v=c;}
			query(rt[id[son[u]]-1],rt[id[v]],x,0,max);
		}
		long res=nsum*x-isum;
		return res;
	}

	public static void main(String[] args) throws IOException {
		//Scanner in=new Scanner(System.in);
		T=nextInt();
		for(int t=1;t<=T;t++)
		{
			n=nextInt();m=nextInt();
			Arrays.fill(head,-1);ee=0;
			for(int i=1;i<n;i++)
			{
				a=nextInt();b=nextInt();
				c=nextInt();
				add(a,b,c);add(b,a,c);
			}
			prepare();
			out.println("Case #"+t+":");
			while(m-->0)
			{
				ss=nextInt();tt=nextInt();
				k=nextInt();
				aa=nextInt();bb=nextInt();
				pp=getmin(ss,tt);
				if(aa<=bb) ans=(long)pp+k/aa;
				else
				{
					ans=(k>=aa)?(k-aa)/bb+1:0;
					k/=bb;
					l=1;r=k;res=0;
					while(l<=r)
					{
						mid=l+(r-l)/2;
						qq=get(ss,tt,pp+mid);
						if(qq<=k) { res=mid;l=mid+1;}
						else r=mid-1;
					}
					ans=Math.max(ans,res)+pp;
				}
				out.println(ans);
			}
		}
		out.flush();
	}
}
/* 
2
2 1
1 2 4
2 1 2 4 3
2 1
1 2 4
2 1 2147483647 2 1
*/

S7-1200 PLC PID功能 | 调节PID参数 阅读详情

相关推荐

从零开始学习信号完整性(SIPI)--2

上一节我们已经谈过,信号完整性研究的是如何使驱动器输出的信号传输到接收器件并被正确的接收。 信号完整性的三要素包含了:信号、驱动接收芯片、传输通道。 这其中信号是主体,我们要做的主要工作就是设计好信号的传输路径为信号的正确传输扫清障碍。要做信号完整性分析与设计首先要了解信号的特性,以及信号质量的判别标准。 对一个信号进行描述通常需要如下几个指标: 信号特性的描述 摆幅:信号从低电平到高电平之间的电压差,对于单端信号通常由信号的供电电压决......

qq_29476769的博客 2万+

【HDU】4729 An Easy Problem for Elfness 可持久化线段树——主席树

传送门:【HDU】4729 An Easy Problem for Elfness ti

poursoul 1175

VS2019 从零构建 OSG+OSGEarth+OSGQt 开发环境实战指南

本文提供了一份详细的实战指南,指导开发者如何在Windows系统下使用VS2019从零开始编译和配置OSG、OSGEarth与OSGQt开发环境。文章涵盖了从环境准备、源码获取、CMake配置、Visual Studio编译到最终测试的完整流程,并分享了关键的避坑技巧,旨在帮助三维GIS与可视化开发者高效搭建稳定、可控的专业开发平台。

weixin_28826961的博客 368

hdu 4729 An Easy Problem for Elfness (树链剖分-入边-二分-查区间最值)

题意: 有K的经费,询问从a->b 通过两种途径取得最大流量是多少 途径1: 加任意的边 途径2:扩充任意的边 思路: 对于每一个操作来说,如果ab的直接连的边必定最合算 如果a>b,那么有两种,第一是扩展原有的边。第二是加一条a->b的边,扩展a->b的边 一开始想复杂了,去搜了下,发现是个很模板的题,但是二分的左边界要处理好。否则会TLE。这题当入边的板子吧!入边入点在编号节点I

GameRoad 397

BLE透传速率调优(二)

摘要:本文分析了蓝牙协议中MDbit=1时应连续发送多包但实际只发一包的问题。通过波形分析和代码调试,发现问题的根源在于接收端出现sync error导致提前关闭接收窗口,而非发送端问题。最终通过调整RF时序参数(将rxpathdly改为13us)解决了TX到RX转换的同步问题,使连接事件能正常发送多个数据包,传输速率提升至70kb/s。文中详细记录了使用逻辑分析仪和trace宏调试的过程,揭示了CEVA芯片设计中TX中断与ACK接收的关联特性。

袁赟的博客 800

告别环境配置烦恼:用Conda一键搞定GATK4、samtools、fastp等生信分析全家桶

本文介绍如何利用Conda快速搭建包含GATK4、samtools、fastp等工具的生物信息学分析环境,解决软件安装和版本冲突问题。通过详细的配置步骤和实战案例,帮助研究者十分钟内完成重测序分析全家桶的环境配置,显著提升上游分析效率。

weixin_30753873的博客 335

HDU 4729 题解

有一棵树,给你边的容量。每次给你s,t,k,a,b,求s到t的最大流。k是总预算,a是加一条边的费用(容量为1),b是扩充一条边的费用。

ez_yww的博客 455

高光谱图像处理和分析软件(包含雷尼绍Renishaw wdf 文件导入解析功能)

是一款基于微软windows操作系统的多传感器成像工具,用于处理和分析高光谱图像。它是一个模块化的系统,由一个基本的引擎,一个图形用户界面,一个化学计量工具箱和可选的用户提供的模块组成。它支持最重要的光谱成像技术,如UV/Vis、红外、拉曼、太赫兹、光发射/吸收和质谱。除此之外,还允许用户将高光谱图像与物理属性图和传统高分辨率彩色照片合并在一起 链接:https://pan.baidu.com/s/1ruQ5YSh5_ZS9wx_V3Q5Oow 提取码:qdx0 ...

业余程序员小徐的博客 8073

HDU 4729 An Easy Problem for Elfness(树链剖分 + 二分)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4729 题意:给出一棵树,每条边有不同的容量,给出多组询问,每次询问给出源点,汇点和预算额,可以任意建一条新边其预算为A,或者将某条边扩大1的容量费用为B,问在预算允许范围内S-T的最大流为多少 思路:在未进行任何操作时,先算出S-T的最大流,其实是树上瓶颈边的容量cap,如果A &l...

Tongqi 725

cadence virtuoso 激励信号源

vpulse,vpwl,vsin,vsource信号源介绍

努力学习的IC小白 3万+

STM32入门教程:自动门控制

通过这个简单的示例,我们展示了如何使用STM32微控制器来实现一个简单的自动门控制系统。如果有物体靠近门口,我们会改变doorState的值,并使用controlServoMotor函数来控制舵机电机的转动。具体的引脚连接可以根据您的具体硬件来定,例如将红外传感器的输出引脚连接到GPIOA_PIN0引脚。同样,具体的引脚连接可以根据您的具体硬件来定,例如将舵机的控制引脚连接到GPIOA_PIN1引脚。首先,我们需要包含必要的库文件和引用。然后,我们需要定义一些函数来处理红外传感器的输入和舵机电机的输出。

m0_75244442的博客 578

HDU 4729 An Easy Problem for Elfness(树链剖分边权+二分)

题意 链接:https://cn.vjudge.net/problem/HDU-4729 给你n个点,然你求两个点s和t之间的最大流.而且你有一定的钱k,可以进行两种操作 1.在任意连个点之间建立一个单位1的流,费用a 2.将原先的流扩大1个单位,费用b 思路 题目已经说了是一棵树,那么树上两点的最大流就是两点路径上的最小值。其实两种操作各一次对最大流的贡献是相等的。我们分类讨论: 如...

autfuhyql782263188的博客 254

QGis二次开发 —— 5.1、基于qgis开发雷达扫描、无人机飞行跟踪等(附:源码及工程)

基于qgis开发雷达扫描、无人机飞行跟踪等

325

HDU 4729 An Easy Problem for Elfness(树上主席树+LCA+二分)

题目大意:给你一棵树,每条边有一个容量。然后m个询问,每个询问是互相独立的,给你两个点S, T,一个预算K, 建一条容量为1的新边的费用A(可以建在任一两个节点之间,包括S,T),将某一条现有的边容量扩大1的费用B。 问从S到T在预算允许的情况下最大流是多少。 这个分两种情况来讨论最优解: 1.如果A≤BA \leq B,显然新建不会比扩展差,可以建立kA\frac{k}{A

KIJamesQi的博客 645

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

HDU-4729 Number

Here are two numbers A and B (0   For each x, f(x) equals to the amount of x’s special numbers.    For example, f(6)=1, because 6 only have one special number which is 4. And f(12)=3, its special n

樱花满地集于我心,楪舞纷飞祈愿相随 394

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

hdu 4729 树链剖分+二分

此题一看就知道是树链剖分,模板题!可怜我模板少抄个字母,在这两百多行的代码里找bug找了三个多小时啊!!!! 解题思路:对于要求的x,y点,先可以求得不加任何操作的最大流量P,c1为建造一个路的话费,c2为增加一个容量的花费,如果c1P+k/c1。 否则,如果先建一条路,那么最大的流量是M=P+1+(k-c1)/c2,如果不新建路只加边呢?那就可以二分求得最大的结果,为了节省时间,可以对整体进

生活总是要微笑着面对~ 1827

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

HDU 4729 An Easy Problem for Elfness (主席树,树上第K大)

转载请注明出处,谢谢http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents    by---cxlove 题意:给出一个带边权的图。对于每一个询问(S , T , K , A , B),有两种操作,加一条单位边花费为A,将某条边流量扩展一个单位花费为B,在预算为K的情况下求S到T最大流的最大值。 http://acm.hdu.edu.cn/showp

窝不是爱酱,喵~~~~ 5204

hdu 4729 An Easy Problem for Elfness,函数式线段树

hdu 4729 An Easy Problem for Elfness,函数式线段树 13年成都网赛的题。 主要是问一个树上的某两个点间的路径,你可以对某些边增加一些流量,最多这个路径上能流过多少流量。 题目意思比较复杂(废话多),最大流量可以分成这几种情况: 1、增加一条边,剩下的费用用来增加这条边的流量,加上本来两点间的流量。 2、所有的费用用来建新边,加上本来的流量。 3、

Necs的小窝 821

【树链剖分】 HDU 4729 An Easy Problem for Elfness 二分

点击打开链接 给出一棵树 每条边有容量 新建一条边(初始值为1) 需要A$  容量增加1 需要B$ 询问  预算有K 使得S->T的流量最大 分三种情况 1. AT路径上最小值+K/A; 2. A > B时 新建一条边再扩容该条边   3. 扩容 S->T路径上的边 使得最小值最大 1和2可以很快的算出 对于第3种情况我们可以二分答案 求解 #include #includ

Kewowlo 533

hdu4729 树链剖分+二分

An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1235Accepted Submission(s): 257 Problem Description Pfct...

diaocuiguo2493的博客 606

Distance on the tree (树链剖分+主席树)

题目:https://nanti.jisuanke.com/t/38229 题意:树上有边权,每次查询树上两点路径上边权小于等于k的数量。 思路:边权下推成点权,树剖化树为区间,区间查找小于k的数的个数。 代码: #include <bits/stdc++.h> #define LL long long using namespace std; typedef pair&lt...

A_Thinking_Reed_的博客 312

HDU 6162 Ch’s gift 【LCA暴力 or 主席树 + 树链剖分】

传送门 题目大意: 一颗树, 树上有点权, 每次询问u, v的树上路径上的点权范围在[a, b]内的权值和是多少. 思路: 这道题居然暴力能过, 而且巨快…. 后面还是写了写正解. 很明显我们需要把u - &amp;gt; v的路径剖下来, 然后问题就变成区间问题了, 询问区间中在一定范围内的数的和, 而我们知道主席树可以做区间中小于等于某个数的和是多少, 所以这个就可以用主席树来维护, 同时维护下&amp;...

Anxdada -- 我等风来也等你 354

训练周记(树剖+主席树)

这周给平衡树开了一个头,这周可能是自打寒假以来最用功的一周了,树链剖分和线段树不说掌握的很透彻,但是模板题打的还是很顺手,还有主席树,比较难理解,虽然感觉平衡树更难理解一些,但是时间剩的不大允许了, 贴一下这后的模板: 树链剖分: vector<int> G[N<<1]; int sz[N],son[N],fa[N],dep[N]; //函数调用 s 为源点:dfs(s,0) void dfs1(int u,int f) //寻找重儿子 { sz[

C_Dreamy的博客 510

bzoj4012 开店 树链剖分&主席树

看题第一眼反应点分治。。。QAQ但是从来没写过动态点分治不会写。        然后扒到了一个树链剖分的题解,发现还是可做的。        考虑一个朴素的问题,如果没有颜色限制,问所有点到u的距离之和是多少?        两点间距离dist(u,v)=deep(u)+deep(v)-2*deep(lca(u,v))。        因此所有点到u的距离之和=deep(u)*n+Σ(i=

lych的博客 2583

BZOJ 4448 主席树+树链剖分(在线)

为什么题解都是离线的…… (抄都没法抄) 搞一棵主席树 1 操作 新树上的当前节点设成1 2 操作 查max(i-xx-1,0)那棵树上这条路径上有多少个点是1 让你找经过了多少个点 查的时候用deep 搞出来就好了 //By SiriusRen #include <cstdio> #include <cstring> #in...

weixin_34414650的博客 203

SPOJ COT - Count on a tree(树链剖分+LCA+主席树,树上第k大)

描述 You are given a tree with N nodes. The tree nodes are numbered from 1 to N. Each node has an integer weight. We will ask you to perform the following operation: u v k : ask for the...

riba2534的博客 980
上一篇: POJ-1330 LCA的两种写法
下一篇: LightOJ-1013 LCS+递推
AC_Machine
博客等级 码龄11年 1粉丝 19原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值