模拟加bfs
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
const int N = 3e5 + 10;
const int mod = 998244353;
void solve() {
int n;
double z,r;
cin>>n>>z>>r;
vector<vector<int>>g(n+1);
vector<double> vt(n+1,0),st(n+1,0); //标记是否得道
for(int i = 0; i < n ; i++){
int k;
cin>>k;
if(k == 0){
double tmp;
cin>>tmp;
vt[i] = tmp;
continue;
}
for(int j = 0 ; j < k ; j++){
int x;
cin>>x;
st[x] = 1;
g[i].push_back(x);
}
}
int str = 0;
for(int i = 0 ; i < n ; i++){
if(st[i] == 0){
str = i;
}
}
queue<pair<int,double>> q;
double sum = 0;
if(vt[str] != 0){
sum += z * 1.0 * vt[str];
q.push({str,z * 1.0 * vt[str]});
}else{
q.push({str,z});
}
while(!q.empty()){
int x = q.front().first;
double val = q.front().second;
q.pop();
// cout<<x<<" "<<val*(1-r*1.0/100)<<endl;
for(auto it : g[x]){
if(vt[it] == 0){
q.push({it,val*(1-r*1.0/100)});
}else{
sum += val*1.0*(1-r*1.0/100) * vt[it];
q.push({it,val*1.0*(1-r*1.0/100) * vt[it]});
}
}
}
cout<<(int)sum<<endl;
}
signed main() {
// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt = 1;
// cin >> tt;
while (tt--) {
solve();
}
return 0;
}