-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathA1106.cpp
More file actions
40 lines (37 loc) · 719 Bytes
/
A1106.cpp
File metadata and controls
40 lines (37 loc) · 719 Bytes
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
39
40
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
const int MAXN = 100000 + 10;
int N, minDepth = MAXN, cnt = 0;
double P, r;
vector<int> node[MAXN];
void DFS(int index, int depth){
if(node[index].size() == 0){
if(depth < minDepth){
minDepth = depth;
cnt = 1;
}else if(depth == minDepth){
++cnt;
}
}else{
for(int i = 0; i < node[index].size(); ++i){
DFS(node[index][i], depth+1);
}
}
}
int main(){
scanf("%d%lf%lf", &N, &P, &r);
r /= 100;
for(int i = 0; i < N; ++i){
int k, child;
scanf("%d", &k);
for(int j = 0; j < k; ++j){
scanf("%d", &child);
node[i].push_back(child);
}
}
DFS(0, 0);
printf("%.4lf %d", P*pow(1+r, minDepth), cnt);
return 0;
}