hiho week 47 register

Ended

Participants:466

Verdict:Accepted
Score:100 / 100
Submitted:2015-05-25 15:54:21

Lang:GCC

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<stdio.h>
#define MAXN 100001
#define MAXM 500001
int head[MAXN+1]={0};// 0
int p[MAXM+1];  // 
int next[MAXM+1]={0};   // 0
int edgecnt;            // 
int N,M,deg[MAXN];
void addedge(int u,int v)
{
    edgecnt++;
    p[edgecnt]=v;
    next[edgecnt]=head[u];
    head[u]=edgecnt;
}
void solve()
{
    int queue[100001],po=0;
    int i;
    for(i=0;i<N;i++)
    {
        if(deg[i]==0)
            queue[po++]=i;
    }
    while(po!=0)
    {
        int v=queue[po-1];
        po--;
        for(i=head[v];i;i=next[i])
        {
            deg[p[i]]--;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX