-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathA1106.cpp
More file actions
48 lines (44 loc) · 1003 Bytes
/
Copy pathA1106.cpp
File metadata and controls
48 lines (44 loc) · 1003 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
41
42
43
44
45
46
47
48
#include<cstdio>
#include<vector>
#include<cmath>
#define MAXN 100005
using namespace std;
int n, lowest_level = MAXN, lowest_level_cnt = 1;
double p, r;
vector<int> tree[MAXN];
// index: 当前节点
// level: 当前层数
void dfs(int index, int level)
{
if (tree[level].empty())
{
if (level < lowest_level)
{
lowest_level = level;
lowest_level_cnt = 0;
}
else if (level == lowest_level_cnt)
lowest_level_cnt++;
return;
}
for (int i = 0; i < tree[index].size(); i++)
dfs(tree[index][i], level + 1);
}
int main()
{
scanf("%d %lf %lf", &n, &p, &r);
lowest_level = n;
for (int i = 0; i < n; i++)
{
int k, id;
scanf("%d", &k);
for (int j = 0; j < k; j++)
{
scanf("%d", &id);
tree[i].push_back(id);
}
}
dfs(0, 0);
printf("%.4lf %d\n", p * pow(1.0 + r / 100.0, lowest_level), lowest_level_cnt);
return 0;
}