题目大意:公司里有一些员工及对应的上级,给出一些员工的关系,分配给某员工任务后,其和其所有下属都会进行这项任务.输入T表示分配新的任务, 输入C表示查询某员工的任务.本题的难度在于建树,一开始百思不得其解,后来看了lx大大的博客后才明白,用递归建立了各个员工之间的关系,Start[x] 表示x员工为Boss的起点,End[x]表示x员工为Boss的终点.之后对这样的整体线段进行赋值即可. #include <stdio.h> #include <algorithm> #includ…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3974 给你T组数据,n个节点,n-1对关系,右边的是左边的父节点,所有的值初始化为-1,然后给你q个操作: 有两种操作: 操作一:T X Y ,将以X为根的子树上的所有节点都变成Y. 操作二:C X,查询第X号点是多少? 没想到是线段树做,就算想到了也想不到用dfs序做... 例子中给你了这样的树: 2 /     \ 3       5 /    \ 4      1 DFS一遍转化成DFS序:2…
描述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,that person is your subordinate, and all his subordin…
Assign the task Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 636    Accepted Submission(s): 322 Problem Description There is a company that has N employees(numbered from 1 to N),every employ…
http://acm.hdu.edu.cn/showproblem.php?pid=3974 Assign the task Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7144    Accepted Submission(s): 2708 Problem Description There is a company that h…
题意:给定一棵树的公司职员管理图,有两种操作, 第一种是 T x y,把 x 及员工都变成 y, 第二种是 C x 询问 x 当前的数. 析:先把该树用dfs遍历,形成一个序列,然后再用线段树进行维护,很简单的线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib>…
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,that person is your subordinate, and all his subordinat…
题目链接:https://vjudge.net/problem/HDU-3974 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,that person is…
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 immediate boss of someone,that person is your subordinate, an…
题意:一共有n名员工, n-1条关系, 每次给一个人分配任务的时候,(如果他有)给他的所有下属也分配这个任务, 下属的下属也算自己的下属, 每次查询的时候都输出这个人最新的任务(如果他有), 没有就输出-1. 题解:需要用DFS建树来确立关系, 然后用线段树进行区间覆盖. DFS建树: 从Boss 开始dfs,通过dfs递归时编号出现的先后顺序来确定某个员工对应的起点与终点. 样例的关系图是这样的 当dfs建树跑完了之后各个节点对应的位置是这样的 其中Start表示这个节点本身的新编号和这个节点…