-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1079.cpp
More file actions
35 lines (34 loc) · 675 Bytes
/
1079.cpp
File metadata and controls
35 lines (34 loc) · 675 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
#include <bits/stdc++.h>
using namespace std;
int n;
double p, r, sum = 0;
vector<vector<int>> adj;
map<int, int> amount;
void dfs(int u, double prize){
if(adj[u].size() == 0){
sum += prize * amount[u];
return;
}
for(int i=0; i<adj[u].size(); i++){
dfs(adj[u][i], prize * r);
}
}
int main(){
//if(freopen("input.txt", "r", stdin)==NULL) return 531529412;
ios::sync_with_stdio(false);
cin>>n>>p>>r;
r = 1 + r / 100;
adj.resize(n);
for(int i=0; i<n; i++){
int k;
cin>>k;
if(k == 0) cin>>amount[i];//mapÄÜÖ±½ÓÊäÈë
else{
adj[i].resize(k);
for(int j=0; j<k; j++) cin>>adj[i][j];
}
}
dfs(0, p);
cout<<fixed<<setprecision(1)<<sum;
return 0;
}