Live2d Test Env

随笔分类 -  树上乱搞---树的分治

摘要:题意:有N座山,M条道路。山有山高,路有困难值(即点权和边权)。现在Q次询问,每次给出(v,p),让求从v出发,只能结果边权<=p的边,问能够到达的山中,第K高的高度(从大到小排序)。 思路:显然,最小化最大边权,需要先得到生成树,三种思路。 第一种:离线+启发式合并,这里先不管。 第二种:Krus 阅读全文
posted @ 2019-09-29 17:06 nimphy 阅读(215) 评论(0) 推荐(0) 编辑
摘要:题意:给定带点权的树,问多少个连通块,其乘积<=M; N<=2000,M<1e6; 思路:连通块-->分治; 由于普通的树DP在合并的时候复杂度会高一个M,所以用依赖背包来做。 (当然,由于体积分布是离散的,可能有些选手用map也可以过,这样避免了每次都for(i,1,M),取决于数据吧)。 那么现 阅读全文
posted @ 2019-08-08 11:12 nimphy 阅读(591) 评论(0) 推荐(1) 编辑
摘要:题意:给定一棵树,有点权a[],有边权。 现在有M次修改点权的操作,输出每次修改后,Σ(a[i]^a[j])*dis(i,j); 思路:因为待修改,我们需要快速得到以及修改一个点到其他所有点的信息。 肯定就是动态点分治了啊。 而异或这个操作没有什么累加的性质,所以每一位拆开单独计算。 根据二进制位置 阅读全文
posted @ 2019-07-19 17:33 nimphy 阅读(280) 评论(0) 推荐(0) 编辑
摘要:题目连接:https://www.luogu.org/problemnew/show/U60884 题意:有N个点,标号为1∼N,用N−1条双向带权通道连接,保证任意两个点能互相到达。 Q次询问,问从编号为x的点到达标号L∼R的点其中一个点的最小距离是多少。 说明 :N,Q<1e5,边权<1e4; 阅读全文
posted @ 2019-07-16 15:21 nimphy 阅读(348) 评论(0) 推荐(0) 编辑
摘要:题目:在一片土地上有N个城市,通过N-1条无向边互相连接,形成一棵树的结构,相邻两个城市的距离为1,其中第i个城市的价值为value[i]。 不幸的是,这片土地常常发生地震,并且随着时代的发展,城市的价值也往往会发生变动。 接下来你需要在线处理M次操作: 0 x k 表示发生了一次地震,震中城市为x 阅读全文
posted @ 2019-07-12 11:31 nimphy 阅读(248) 评论(0) 推荐(0) 编辑
摘要:(由于先看的最后一题,然后又一直WA,导致这场有点爆炸,我背锅。 A .Fancy Antiques 题意: 选择最多k个商店,买n个物品,每个物品分别对应两个店售卖,求最小花费是多少。n<100,k=m<=40; 思路:搜索。。。。开始以为是个费用流,然后没法限制。加N多减枝,然后.... B. 阅读全文
posted @ 2019-03-15 14:00 nimphy 阅读(675) 评论(0) 推荐(0) 编辑
摘要:题意:给定带点权边权的树,定义路径的花费=路径边权和e+起点点权w[s]*终点点权w[t]。N<2e5,e,w<1e6; 思路:首先,需要树分治。 然后得到方程dp[i]=min{ dis[i]+dis[j]+w[i]*w[j] },很显然需要斜率优化。 注意维护凸包的时候是需要保证w[j]是单调的 阅读全文
posted @ 2019-03-15 13:23 nimphy 阅读(437) 评论(0) 推荐(0) 编辑
摘要:You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to ai . Let's denote the function g 阅读全文
posted @ 2019-01-12 10:01 nimphy 阅读(864) 评论(0) 推荐(0) 编辑
摘要:题意:T组样例,给次给出一个N节点的点权树,以及M,问连通块的点权和sum的情况,输出sum=1到M,用0或者1表示。 思路:背包,N^2,由于是无向的连通块,所以可以用分治优化到NlgN。 然后背包可以用bitset优化。注意不要想着背包合并背包,背包只能合并单点。 阅读全文
posted @ 2018-09-24 09:18 nimphy 阅读(796) 评论(0) 推荐(0) 编辑
摘要:You are given a tree consisting of nn vertices. A number is written on each vertex; the number on vertex ii is equal to aiai. Let's denote the functio 阅读全文
posted @ 2018-06-14 18:07 nimphy 阅读(849) 评论(0) 推荐(0) 编辑
摘要:After the success of 2nd anniversary (take a look at problem FTOUR for more details), this 3rd year, Travel Agent SPOJ goes on with another discount t 阅读全文
posted @ 2018-05-25 16:29 nimphy 阅读(362) 评论(2) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2018-05-24 15:21 nimphy 阅读(289) 评论(0) 推荐(0) 编辑
摘要:Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v. Give an in 阅读全文
posted @ 2017-12-19 21:47 nimphy 阅读(283) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示