hiho week 48 register

Ended

Participants:456

Verdict:Accepted
Score:100 / 100
Submitted:2015-05-31 11:00:26

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 <cstdio>
#include <vector>
using namespace std;
const int Max=100001;
const int MOD=142857;
int N,M,K,V[Max];
vector<int> fathers[Max];
bool done[Max];
void calc(int pos)
{
    if(done[pos])return;
    done[pos]=true;
    for(int i=0;i<fathers[pos].size();++i)
    {
        if(!done[fathers[pos][i]])
            calc(fathers[pos][i]);
        V[pos]+=V[fathers[pos][i]];
        V[pos]%=MOD;
    }
}
void print()
{
    for(int i=1;i<=N;++i)
        printf("%d ",V[i]);
    printf("\n");
}
int main()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX