题意:给一棵树,三种操作。将第i条边的权值改为v,将a到b的路径上的边的权值全部取反,求a到b路径上边的权值的最大值。
思路:明显的树链剖分,加上线段树的操作。因为有取反的操作所以每个区间要记录最大值和最小值。查询两点间的路径时,用求公共祖先的方式去求。
#include<iostream>
#include<stdio.h>
#include<string.h>
const int N=101000;
const int inf=0x3fffffff;
using namespace std;
int head[N],num,son[N],sz[N],father[N],dep[N],idx,a[N],cot[N],ti[N],top[N];
struct edge
{
int st,e......
阅读全文