随笔分类 -  树的全家桶/ 树形DP/ LCA/MST/树链剖分

摘要:2020CCPC [Weihai Site]-C. Rencontre(树,贡献) 题面: 题意: 给定一个含有$\mathit n$个节点的树,每一个边都有其边权,现在有三个科学家,每一个科学家都有一个节点列表,代表他今晚会从列表中等概率的选择一个节点住下。每个科学家的选择相互独立,都是等概率的。 阅读全文
posted @ 2020-11-11 16:21 茄子Min 阅读(219) 评论(0) 推荐(0)
摘要:[2020-CCPC Changchun Onsite]-F. Strange Memory(dsu on tree) 题面: 题意: 给定一个含有$\mathit n$个节点的数,求下式的值。 \[ \sum\limits_{i=1}^n\sum\limits_{j=i+1}^n [a_i \op 阅读全文
posted @ 2020-11-09 17:35 茄子Min 阅读(594) 评论(1) 推荐(1)
摘要:HDU-5956-The Elder(斜率优化树形DP,队列还原) 题目链接: HDU - 5956 题面: 题意: 给定一颗含有$\mathit n$个节点,\(\text 1\) 节点为根的有根树,每一个边的有个边权。 可以从根节点派出一个青蛙去每一个节点,青蛙移动距离为$\mathit L$ 阅读全文
posted @ 2020-10-29 11:45 茄子Min 阅读(113) 评论(0) 推荐(0)
摘要:[Codeforces Round #595 (Div. 3)] F. Maximum Weight Subset (树形DP) 题面: 题意: 给定一棵树,每一个节点有一个权值$a_i$,让你选择一个节点子集$\mathit S$,使其集合中任意两点的距离大于$\mathit k$,且集合这中点权 阅读全文
posted @ 2020-10-11 00:55 茄子Min 阅读(111) 评论(0) 推荐(0)
摘要:BZOJ #2238. Mst (最小生成树+树链剖分+线段树) Description 给出一个N个点M条边的无向带权图,以及Q个询问,每次询问在图中删掉一条边后图的最小生成树。(各询问间独立,每次询问不对之后的询问产生影响,即被删掉的边在下一条询问中依然存在) Input 第一行两个正整数N,M 阅读全文
posted @ 2020-09-04 21:55 茄子Min 阅读(256) 评论(0) 推荐(0)
摘要:HDU-6866 ,Linuber File System(树形DP) 题意: 给定一个1号节点为根的树,每一个节点有一个区间$[L_i,R_i]$,初始时每一个节点的权值都为0,每一次操作可以选择一个节点,将以该点为根的子树中所有节点的权值加上任意一个整数(可以为负值)。 现在问最少需要操作多少次 阅读全文
posted @ 2020-08-15 15:57 茄子Min 阅读(264) 评论(0) 推荐(1)
摘要:杭电多校03 HDU-6765 Count on a Tree II Striking Back(概率论,树链剖分) Problem Description You are given a tree with n nodes. The tree nodes are numbered from 1 t 阅读全文
posted @ 2020-08-05 22:07 茄子Min 阅读(346) 评论(0) 推荐(0)
摘要:HDU-6793 - Tokitsukaze and Colorful Tree (dfs序列,树状数组,离线) 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6793 题面: 思路: 首先分析答案的计算公式: node v is not an anc 阅读全文
posted @ 2020-07-29 21:36 茄子Min 阅读(341) 评论(0) 推荐(0)
摘要:[Educational Codeforces Round 32] -G. Xor-MST(01字典树,分治) 题意: 给定一个含有$\mathit n$个节点的完全图,每一个节点有个数字$a_i$,节点$\mathit i$和节点$\mathit j$之间的边权为$a_i\oplus a_j$。 阅读全文
posted @ 2020-07-26 17:30 茄子Min 阅读(481) 评论(0) 推荐(1)
摘要:[2020 年百度之星·程序设计大赛 - 初赛一] 1005 -Rotate (期望,树,推公式) 比赛链接: http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=889 题意: 思路: 因为$\mathit a$序列是单调不减的,所以 阅读全文
posted @ 2020-07-20 01:33 茄子Min 阅读(337) 评论(0) 推荐(0)
摘要:[Bubble Cup 12 - Finals [Div. 1]] -D. Xor Spanning Tree (仙人掌图扣环,FWT) 思路: 首先用类似Tarjan算法的方法把图中的每一个环单独的取出来。 我们知道不在环中的边一定要取的,所以可以求出$base$代表不在环中的边的权值异或和。 然 阅读全文
posted @ 2020-07-17 19:13 茄子Min 阅读(196) 评论(0) 推荐(0)
摘要:[AtCoder Beginner Contest 163] F path pass i (树型dfs,容斥定律) 链接:https://atcoder.jp/contests/abc163/tasks/abc163_f Problem Statement We have a tree with N 阅读全文
posted @ 2020-04-21 17:37 茄子Min 阅读(500) 评论(1) 推荐(0)
摘要:[Codeforces Round 624 (Div. 3)] E. Construct the Binary Tree (构造二叉树) E. Construct the Binary Tree time limit per test 2 seconds memory limit per test 阅读全文
posted @ 2020-03-13 17:33 茄子Min 阅读(225) 评论(0) 推荐(0)
摘要:[Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated] D. Kuroni and the Celebration(交互题+树的性质) This is an interactive problem. After getting AC after 13 Tim 阅读全文
posted @ 2020-03-04 15:24 茄子Min 阅读(187) 评论(0) 推荐(0)
摘要:牛客练习赛58 F XOR TREE(结论+树链剖分+线段树) 链接:https://ac.nowcoder.com/acm/contest/4090/F 来源:牛客网 XOR TREE 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bi 阅读全文
posted @ 2020-03-01 01:20 茄子Min 阅读(521) 评论(0) 推荐(0)
摘要:AtCoder Beginner Contest 152 F Tree and Constraints (容斥定理+树上路径的性质) We have a tree with NN vertices numbered 11 to NN. The ii th edge in this tree conn 阅读全文
posted @ 2020-02-27 00:16 茄子Min 阅读(527) 评论(0) 推荐(0)
摘要:2018牛客国庆集训派对Day1 D Love Live! (01字典数+树上启发式合并/静态链分治) 链接:https://ac.nowcoder.com/acm/contest/201/D 来源:牛客网 Love Live! 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 104 阅读全文
posted @ 2020-02-22 22:19 茄子Min 阅读(229) 评论(0) 推荐(0)
摘要:[Codeforces Round 620 (Div. 2)] E. 1 Trees and Queries time limit per test 4 seconds memory limit per test 512 megabytes input standard input output s 阅读全文
posted @ 2020-02-17 21:42 茄子Min 阅读(261) 评论(0) 推荐(0)
摘要:Codeforces Round 615 (Div. 3) F. Three Paths on a Tree 题目链接:https://codeforces.com/contest/1294/problem/F time limit per test 2 seconds memory limit p 阅读全文
posted @ 2020-01-28 17:47 茄子Min 阅读(326) 评论(0) 推荐(0)
摘要:D. Numbers on Tree 构造,树dfs 题目链接:https://codeforces.com/contest/1287/problem/D、 D. Numbers on Tree time limit per test 1 second memory limit per test 2 阅读全文
posted @ 2020-01-18 16:18 茄子Min 阅读(421) 评论(0) 推荐(0)