[Offer收割]编程练习赛24 register

Ended

Participants:356

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-27 13:21:41

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int lazy[maxn<<1];
int l[maxn],r[maxn];
int h[maxn],mem;
struct
{
    int v,next;
}e[maxn];
void add(int u,int v)
{
    e[mem].v=v;
    e[mem].next=h[u];
    h[u]=mem++;
}
int a[maxn],ans[maxn];
int shit[maxn];
int cnt;
void dfs(int u)
{
    shit[cnt]=u;
    l[u]=cnt++;
    for(int i=h[u];i+1;i=e[i].next)
    {
        int v=e[i].v;
        ans[v]=ans[u]+1;
        dfs(v);
    }
    r[u]=cnt-1;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX