Light 1348 - Aladdin and the Return Journey
题目链接
树链剖分基础题,注意一个坑点,就是下标按0开始的话按我的写法是会错的,因为son初值赋成0了,要么改一下son初值,要么把下标都+1
代码:
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 30005;
int dep[N], fa[N], son[N], sz[N], top[N], id[N], idx;
int first[N], next[N * 2], vv[N * 2];
void dfs1(int u, int f, int d) {
dep[u] = d;
sz[u] = 1;
fa[u] = f......
阅读全文