LOJ146DFS 序 3,树上差分 1
LOJ146 这道题可以说是真的板子题啦 恩一看就想到了树链剖分,于是乎很快码出了代码 Code1: 1 #include <bits/stdc++.h> 2 #define ll long long 3 #define ls x << 1 4 #define rs x << 1 | 1 5 using namespace std; 6 ll read() { 7 ll re = 0, f = 1; 8 char ch = getchar(); 9 while (ch < '0' || ch > '9') {if (ch == '-') f = -f; ch = getchar();} 10 while ('0' <= ch && ch <= '9') {re = re * 10 + ch - '0'; ch = getchar();} 11 return re * f; 12 } 13 const int N = 1e6 + 7; 14 int n, m, r; 15 int tot, head[N]; 16 ll sum[N << 2], lazy[N << 2]; 17 ll Id, w[N], wt[N], id[N], fa[N], top[N], siz[N], son[N], dep[N]; 18 struct node{ 19 int net, to; 20 }e