MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | AC
Submitted:2015-05-09 15:29:59

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 <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
long long sum1[100005],to[200005],head[100005],nex[200005],u,v,s,a[100005],vis[100005],ed_num,n,ans,sum[100005];
void addedge(long long fro,long long too)
{
    to[ed_num]=too;
    nex[ed_num]=head[fro];
    head[fro]=ed_num;
    ed_num++;
}
void dfs(long long now,long long fa)
{
    vis[now]=1;
    if (sum1[now]==0) return;
    for (long long ee=head[now];ee!=-1;ee=nex[ee])
    {
        if (!vis[to[ee]])
        {
            dfs(to[ee],now);
        }
    }
    if (a[now]<=0) {a[fa]+=a[now]-1; a[now]=1;}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX