#include <cstdio>
#include <vector>
#include<queue>
#include<algorithm>
using namespace std;
struct node
{
double layer;
int a;
vector<int>child;
}Node[111100];
int n;
double u,p;
double sum = 0;
void Bfs(int root)
{
queue<int>q;
q.push(root);
while(!q.empty())
{
int s = q.front();
q.pop();
for(int i = 0;i<Node[s].child.size();i++)
{
int cid = Node[s].child[i];
Node[cid].layer = Node[s].layer * (1 + p*0.01);
q.push(cid);
}
if(Node[s].child.size() == 0)
sum += Node[s].a * Node[s].layer;
}
}
int main()
{
scanf("%d%lf%lf",&n,&u,&p);
Node[0].layer = u;
for(int i = 0;i<n;i++)
{
int t;
scanf("%d",&t);
for(int j = 0;j<t;j++)
{
int id;
scanf("%d",&id);
Node[i].child.push_back(id);
}
if(t == 0)
{
int a;
scanf("%d",&a);
Node[i].a = a;
}
}
Bfs(0);
printf("%.1lf",sum);
}
1079 Total Sales of Supply Chain (25 分)(BFS)
最新推荐文章于 2020-09-04 17:24:55 发布