# [bzoj4919][splay]大根堆

4919: [Lydsy1706月赛]大根堆

Time Limit: 10 Sec Memory Limit: 256 MB
Submit: 500 Solved: 225
[Submit][Status][Discuss]
Description

Input

## sol:

#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<set>
#include<iostream>
#define it multiset<int>
using namespace std;
typedef long long ll;
typedef double db;
int n,m;
{
char c;
int res,flag=0;
while((c=getchar())>'9'||c<'0') if(c=='-')flag=1;
res=c-'0';
while((c=getchar())>='0'&&c<='9') res=(res<<3)+(res<<1)+c-'0';
return flag?-res:res;
}
const int N=410000;
int tot,fir[N],go[N],nex[N];
{
nex[++tot]=fir[x];fir[x]=tot;go[tot]=y;
nex[++tot]=fir[y];fir[y]=tot;go[tot]=x;
}
it q[N];
int a[N];
inline void dfs(int u,int f)
{
int e,v;
it::iterator i;
for(e=fir[u];v=go[e],e;e=nex[e])
if(v^f)
{
dfs(v,u);
if(q[u].size()<q[v].size()) q[u].swap(q[v]);
for(i=q[v].begin();i!=q[v].end();++i) q[u].insert(*i);
}
i=q[u].lower_bound(a[u]);
if(i!=q[u].end()) q[u].erase(i);
q[u].insert(a[u]);
}
int main()
{
//  freopen("4919.in","r",stdin);
//  freopen("4919.out","w",stdout);