DFS序
UCAS王小二
不念过去,不畏未来...
展开
-
HDU 3974 Assign the task【DFS序+线段树区间染色】
Problem Description 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 immediat原创 2018-02-01 00:13:57 · 284 阅读 · 0 评论 -
hdu 3887 Counting Offspring【DFS序+树状数组】
Problem Description You are given a tree, it’s root is p, and the node is numbered from 1 to n. Now define f(i) as the number of nodes whose number is less than i in all the succeeding nodes of nod原创 2018-02-01 17:48:13 · 251 阅读 · 0 评论 -
POJ 3321 Apple Tree【DFS序+线段树】
Apple Tree Description 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原创 2017-10-27 20:52:18 · 471 阅读 · 0 评论 -
Codeforces 620E New Year Tree【DFS序+线段树区间染色+二进制思维+位运算】
The New Year holidays are over, but Resha doesn’t want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree. The New Year tree is原创 2018-02-01 23:56:42 · 301 阅读 · 0 评论 -
DFS序详解
树通常有多种类型,但其终归是非线性结构,操作起来有时总是那么费时。 例如:POJ 3321 给你一棵树,树上每个节点都有1个苹果,然后你对一个节点操作,如果有苹果就拿走,没苹果就放上,然后询问你以x为根的子树上共有多少个苹果。 每次更新都要遍历一遍,查询也要遍历一遍,时间复杂度很高。如果能转化成线性结构就可以了,就可以用线段树或者树状数组等其他方法对树高效更新和查询。 DFS序就是将树原创 2018-02-02 10:50:37 · 2134 阅读 · 0 评论 -
POJ 2553 The Bottom of a Graph【Tarjan+缩点染色】
The Bottom of a Graph Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 11623 Accepted: 4784 Description We will use the following (standard) definitions from graph theory. Le...原创 2018-02-18 18:20:17 · 213 阅读 · 0 评论