
dfs序
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【POJ - 3321】 Apple Tree(dfs序 + 线段树维护 或 dfs序 + 树状数组维护)
题干:There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tree h...原创 2018-08-09 19:03:17 · 320 阅读 · 0 评论 -
【HDU - 3974】 Assign the task (dfs序 + 线段树维护 区间更新+ 单点查询)
题干:There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,...原创 2018-08-09 20:35:23 · 378 阅读 · 0 评论 -
【HihoCoder - 1881】特殊任务 (树形图,遍历)
题干:H公司一共有N名员工,编号1~N,其中CEO是1号员工。除了CEO之外,其他员工都有唯一的直接上司,所以N名员工上下级关系恰好形成了一棵树形结构。 我们知道每一名员工向H公司的代码库贡献了多少行代码。具体来说,第i名员工贡献了Ai行代码。现在有一项特殊的任务需要2名员工完成,这两名员工需要满足:1. 其中一名是另一名的直接或者间接上司2. 两人贡献代码行数的差值越大越好...原创 2018-11-19 15:13:52 · 337 阅读 · 0 评论 -
【牛客 - 368B】选点(dfs序,LIS 或 dfs序 + 树状数组 + 离散化,树状数组求LIS的方法)
题干: 有一棵n个节点的二叉树,1为根节点,每个节点有一个值wi。现在要选出尽量多的点。对于任意一棵子树,都要满足:如果选了根节点的话,在这棵子树内选的其他的点都要比根节点的值大;如果在左子树选了一个点,在右子树中选的其他点要比它小。输入描述: 第一行一个整数n。第二行n个整数wi,表示每个点的权值。接下来n行,每行两个整数a,b。第i+2行表示第i个节点...原创 2019-02-16 00:09:29 · 244 阅读 · 0 评论 -
【HDU - 5468】Puzzled Elena(容斥原理,dfs序,数学,素因子分解,有坑)
题干: Problem Description Since both Stefan and Damon fell in love with Elena, and it was really difficult for her to choose. Bonnie, her best friend, suggested her to throw a question to them,...原创 2019-07-15 14:37:22 · 252 阅读 · 0 评论