链接
https://www.luogu.org/problem/show?pid=3637
题解
对边操作的LCT,把边化成点,然后操作。
这道题目从a到b和从b到a是不一样的,所以在reverse的时候要将权值乘-1。
代码
//LCT
#include <cstdio>
#include <algorithm>
#define maxn 500000
using namespace std;
int N, M, K, Q;
struct node
{
int rev, w, sum;
node *f, *ch[2];
}nd[maxn], *s[maxn];
inline int getwh(node *x)
{if(!x->f)return -1;if(x->f->ch[