![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
点分治
tomjobs
别慌,慌也没用
展开
-
2019香港区域赛gym102452 C. Constructing Ranches(点分治)
Ranching and the cowboy tradition originated in Spain, out of the necessity to handle large herds of grazing animals on dry land from horseback. During the Reconquista, members of the Spanish nobility and various military orders received large land grants原创 2020-10-19 00:18:10 · 611 阅读 · 0 评论 -
杭电多校第10场 hdu6881 Tree Cutting(点分治)
Problem DescriptionGiven a tree (connected undirected graph with n vertexes and n−1 edges), you are required to delete as few vertexes as possible such that the remaining graph is still a tree and its diameter shall not exceed k. The diameter of a tree is原创 2020-09-29 13:12:53 · 353 阅读 · 0 评论 -
P4178 Tree(点分治)
题目描述给定一棵 nn 个节点的树,每条边有边权,求出树上两点距离小于等于 kk 的点对数量思路:就是裸的点分治,每次找到重心遍历,然后求出所有路径双指针搞一下。数据开到了4e4,卡常,极限优化常数后,最后发现是unordered_map的问题,说好的O(1)查询呢??#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vect原创 2020-09-29 12:24:09 · 174 阅读 · 0 评论 -
Distance in Tree CodeForces - 161D(树形dp,点分治,路径长度为k)
A tree is a connected graph that doesn’t contain any cycles.The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.You are given a tree with n vertices and a positive number k. Find the number of原创 2020-07-03 23:44:02 · 267 阅读 · 0 评论 -
P3806 【模板】点分治1
题目描述给定一棵有 nn 个点的树,询问树上距离为 kk 的点对是否存在。思路:直接在点分治模板的双指针上加上了100次询问(竟然没有T)#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <iostream>#include &l原创 2020-09-28 10:00:33 · 191 阅读 · 0 评论 -
ACWING 252. 树(点分治)
给定一个有N个点(编号0,1,…,N-1)的树,每条边都有一个权值(不超过1000)。树上两个节点x与y之间的路径长度就是路径上各条边的权值之和。求长度不超过K的路径有多少条。输入格式输入包含多组测试用例。每组测试用例的第一行包含两个整数N和K。接下来N-1行,每行包含三个整数u,v,l,表示节点u与v之间存在一条边,且边的权值为l。当输入用例N=0,K=0时,表示输入终止,且该用例无需处理。输出格式每个测试用例输出一个结果。每个结果占一行。数据范围N≤10000输入样例:5 4原创 2020-06-06 11:19:57 · 318 阅读 · 0 评论