随笔分类 - 数据结构--树分治
摘要:题:http://acm.hdu.edu.cn/showproblem.php?pid=6268 题意:给定n个点的树,和一个数m,求树中是否子图点权和为1~m 分析:关键是找subgraph,平时的点分治都是找路径的,这时我们可以结合bitset,每个节点都是一个bitset,每次父亲u保留自己状
阅读全文
摘要:题:http://acm.hdu.edu.cn/showproblem.php?pid=6881 题意:给定n个节点的树,问删除尽可能小的点使得树的直径不超过K,输出最小删除的点数,(1<=k<=n<=3e5) 分析: 核心:枚举中间点或中间边; 枚举中间点的情况是k是偶数,因为直径长可被“劈”成均
阅读全文
摘要:poj1741 题:http://poj.org/problem?id=1741 题意:给定树,和一个树k,问有多少个点对之间的路径是不超过k #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> usin
阅读全文
摘要:题:https://nanti.jisuanke.com/t/41403 题意:求任意俩点之间距离之和模3后的三个结果的总数(原距离之和) 第一种做法: 树形dp #include<bits/stdc++.h> using namespace std; #define pb push_back ty
阅读全文

浙公网安备 33010602011771号