ICode9

精准搜索请尝试: 精确搜索
  • P3384 【模板】轻重链剖分2021-06-11 20:03:24

    题目 题目 思路 树剖终于A了…… 定义: · 重儿子:所有儿子中儿子最多的一个儿子 · 重边:连接2个重儿子的边 · 重链:由重边构成的链 步骤1:先一个dfs,求深度,子树大小,重儿子 步骤2:再一个dfs,按先重再轻的优先级求dfs序,并求每条重链的深度最小的节点,设为top,并将每个节点用dfs序映

  • P3384 【模板】轻重链剖分2020-12-16 00:01:07

    #include<stdio.h> #include<iostream> #include<algorithm> using namespace std; const int maxn=2e5+10; int arr[maxn],w[maxn],n,p; struct node { int v,nxt; }e[maxn<<1]; int head[maxn],cnt; int dep[maxn],fa[maxn],siz[maxn],son[maxn],i

  • 洛谷 P3384 【模板】轻重链剖分2020-11-29 22:36:04

    传送门 #include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<int, int>; const int maxn(1e5 + 10); const int maxm(2e5 + 10); int mod, ecnt, v[maxn], head[maxn]; int dep[maxn], siz[maxn], fa[maxn], son[maxn]; int tim,

  • P3384 【模板】树链剖分2019-09-27 19:01:25

      大佬博客:https://www.cnblogs.com/chinhhh/p/7965433.html#firstt 题目描述 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z 操作2: 格式: 2 x y 表示求树从x到y结点最短路

  • 树链剖分模板 洛谷P33842019-09-12 19:05:40

    #include <cstdio> const int maxn = 200000+10; struct edge{ int v, next; }e[maxn << 1]; //N、M、R、mod,分别表示树的结点个数、操作个数、根节点序号和取模数 int n, m ,r , mod, len = 1, cnt, code , x, y, z; //cnt是重新进行编号的 编号 int w[maxn]; //保存

  • P3384 【模板】树链剖分2019-07-23 14:43:47

    #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN=2*1e6+10; #define ls k<<1 #define rs k<<1|1 inline char nc() { static char buf[MAXN],*p1=buf,*p2=buf; return p1==p2&&(p

  • Luogu P3384 【模板】树链剖分2019-04-19 21:47:39

    。。。rt。。。安利一发大佬博客https://www.cnblogs.com/ivanovcraft/p/9019090.html 注意:不要把dfn和rw弄混了。。。 #include<cstdio>#include<iostream>#define ll long long#define R register ll#define ls (tr<<1)#define rs (tr<<1|1)const int M=100010;using namesp

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有