正文
增加 15 行删除 15 行
75 行未改动76777879808182838439 行未改动12412512612712812913013113236 行未改动1691701711721731741751761771781791801811821831841851861871881897 行未改动19719819920020120220320420520620720820921021121221321421521621721821922022122222322422562 行未改动2882892902912922932942952965 行未改动30230330430530630730830931016 行未改动32732832933033133233333433533633733833934034134234334475 行未改动vector<Edge> e[N];ll d[N] = {};int cur = 0, dfn[N], st[20][N], pw[20], lg[N];namespace LCAs { //LCA和distvoid dfs(int x, int pr) {dfn[x] = ++cur;st[0][dfn[x]] = pr;for (auto i: e[x])39 行未改动int crt;vector<int> g[N]; //点分树int fa[N];namespace Comp { //求点分树int sz[N];int tot;bool vis[N];void getsz(int x, int pr) {36 行未改动}void prework() {crt = solve(1);}}const int M = N * 70;int cnt;struct Node { //左右儿子,代表的边权,贡献次数int l, r;ll val;int cnt;} tr[M];int bel[N];namespace Deg3 { //三度化void calc(int &p, int l, int r, int u) {if (l > r)return ;if (l == r) {7 行未改动calc(tr[p].r, m + 1, r, u);fa[tr[p].l] = fa[tr[p].r] = p;}void build(int x) {for (auto i: g[x])build(i);bel[x] = x;if (g[x].size() >= 2)calc(x, 0, g[x].size() - 1, x);else if (!g[x].empty())tr[x].l = g[x][0];}void prework() {cnt = n;build(crt);}}//每个点维护:子树内的点到我的距离和、子树内有效点数,子树内的点到父亲的距离和//搞两颗可持久化//为了找到这个版本的结点,必须从rt[pos]开始向下访问,不能向上,太变态了vector<int> vec;struct Tree { //F,G是两颗可持久化的树根们int rt[N];} F, G;void mdf2(int i, int preF, int preG, int &nowF, int &nowG, int nw, int x) {62 行未改动for (int i = 1, u, v, w; i < n; i++) {cin >> u >> v >> w;e[u].pb(Edge(v, w));e[v].pb(Edge(u, w));}LCAs::prework();Comp::prework();Deg3::prework();5 行未改动// return ;F.rt[0] = G.rt[0] = crt;for (int i = 1; i <= n; i++)mdf(i);ll lstans = 0;ll mod = 1 << 30;while (q--) {16 行未改动x = lstans ^ x;swap(p[x], p[x + 1]);mdf(x);}}}int main() {// freopen("P15650_19.in", "r", stdin);// freopen("1.out", "w", stdout);ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int subid, T = 1;// cin >> subid >> T;while (T--)slv();return 0;}```75 行未改动76777879808182838439 行未改动12412512612712812913013113236 行未改动1691701711721731741751761771781791801811821831841851861871881897 行未改动19719819920020120220320420520620720820921021121221321421521621721821922022122222322422562 行未改动2882892902912922932942952965 行未改动30230330430530630730830931016 行未改动32732832933033133233333433533633733833934034134234334475 行未改动vector<Edge> e[N];ll d[N] = {};int cur = 0, dfn[N], st[20][N], pw[20], lg[N];namespace LCAs { //LCA和distvoid dfs(int x, int pr) {dfn[x] = ++cur;st[0][dfn[x]] = pr;for (auto i: e[x])39 行未改动int crt;vector<int> g[N]; //点分树int fa[N];namespace Comp { //求点分树int sz[N];int tot;bool vis[N];void getsz(int x, int pr) {36 行未改动}void prework() {crt = solve(1);}}const int M = N * 70;int cnt;struct Node { //左右儿子,代表的边权,贡献次数int l, r;ll val;int cnt;} tr[M];int bel[N];namespace Deg3 { //三度化void calc(int &p, int l, int r, int u) {if (l > r)return ;if (l == r) {7 行未改动calc(tr[p].r, m + 1, r, u);fa[tr[p].l] = fa[tr[p].r] = p;}void build(int x) {for (auto i: g[x])build(i);bel[x] = x;if (g[x].size() >= 2)calc(x, 0, g[x].size() - 1, x);else if (!g[x].empty())tr[x].l = g[x][0];}void prework() {cnt = n;build(crt);}}//每个点维护:子树内的点到我的距离和、子树内有效点数,子树内的点到父亲的距离和//搞两颗可持久化//为了找到这个版本的结点,必须从rt[pos]开始向下访问,不能向上,太变态了vector<int> vec;struct Tree { //F,G是两颗可持久化的树根们int rt[N];} F, G;void mdf2(int i, int preF, int preG, int &nowF, int &nowG, int nw, int x) {62 行未改动for (int i = 1, u, v, w; i < n; i++) {cin >> u >> v >> w;e[u].pb(Edge(v, w));e[v].pb(Edge(u, w));}LCAs::prework();Comp::prework();Deg3::prework();5 行未改动// return ;F.rt[0] = G.rt[0] = crt;for (int i = 1; i <= n; i++)mdf(i);ll lstans = 0;ll mod = 1 << 30;while (q--) {16 行未改动x = lstans ^ x;swap(p[x], p[x + 1]);mdf(x);}}}int main() {// freopen("P15650_19.in", "r", stdin);// freopen("1.out", "w", stdout);ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int subid, T = 1;// cin >> subid >> T;while (T--)slv();return 0;}```