-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCCC-07-S4.cpp
38 lines (34 loc) · 894 Bytes
/
CCC-07-S4.cpp
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
32
33
34
35
36
37
38
#include <bits/stdc++.h>
#define ll long long
#define byte unsigned char
#define vi std::vector<int>
#define printi(a) printf("%d\n",a)
#define printii(a,b) printf("%d %d\n",a,b)
#define scani(a) scanf(" %d",&a)
#define scanii(a,b) scanf(" %d %d",&a,&b)
#define scanNewi(a) int a; scanf(" %d",&a)
#define scanNewii(a,b) int a,b; scanf(" %d %d",&a,&b)
#define fi(var, initial, max) for(int var=initial; var<max; ++var)
#define fd(var, initial, least) for(int var=initial; var>least; --var)
vi points[10010];
int paths[10010];
int main() {
memset(paths, 0, sizeof(int)*10010);
scanNewi(n);
scanNewii(x, y);
while(x != 0) {
points[x].push_back(y);
scanii(x, y);
}
fd(i, n-1, 0) {
fi(j, 0, points[i].size()) {
if(points[i][j] == n) {
++paths[i];
} else {
paths[i] += paths[points[i][j]];
}
}
}
printi(paths[1]);
return 0;
}