wangdy带佬给的权值线段树模板
实为1027练习题C-遥色点对题解 给出一张由编号1到n的n个点和m条边构成的无向图。每条边都有一定的长度。 定义,一条路径的“代价”:该路径上最长一条边的长度。 定义,点x到点y的“点距”:点x到点y的最小代价。 图中每个点都被涂上了颜色,第i号点的颜色编号为Ci。 满足x<y 且|Cx-Cy|>=K 的任意一对点(x,y)都被称为“遥色点对” 现在需要你求出图中所有遥色点对的点距之和。 动态开点线段树启发式合并 #include<stdio.h> #include<bits/stdc++.h> #define f(a,b,c) for(register int a=(b);a<=(c);++a) #define ff(a,b,c) for(register int a=(b);a>=(c);--a) #define ll long long #define max(a,b) ((a)>(b)?(a):(b)) //#define int long long char pbuf[1<<20],*pp1=pbuf; inline void push(char c){*pp1=c;pp1=(pp1-pbuf==(1<<20)-1)?(fwrite(pbuf,1,1<<20,stdout),pbuf):(pp1+1);} //#define pc push #define pc