/**
[线段数]hdu 4366 Successor
在能力值大于自身能力的子孙中找一个最大忠诚值的取代自己
一个很好的线段树,关键在于思维要到。
先dfs标记时间戳将树形结构转化为线性结构
建树
将能力值从大到小排序后依次查询,插入
题目保证了每个staff的loyty不一样,故可以给他和编号做个映射。
*/
#include <stdio.h>
#include <string.h>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
#define N 100000
#define L(i) (i << 1)
#define R(i) (i << 1 | 1)
int titamp = 0;
vector<int> g[N];
map<int,int> mp;
struct _staff
{
int loy,abt,id;
void input(int i)
{
int f;
scanf("%d%d%d",&f,&loy,&abt);
g[f].push_back(i);
id = i;
mp[loy] = i;
}
}sta[N];
struct _st
{
int l,r,maxx;
int mid()
{
return (l + r) >> 1;
}
}st[N<<1];
boo
[线段数]hdu 4366 Successor
最新推荐文章于 2019-05-23 19:13:46 发布
