# HDU-4318 Power transmission 模型转化

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#define eps 1e-6
using namespace std;

int head[50005], N, idx, S, T, P, q[10000005], visit[50005];
double dis[50005];

struct Edge
{
int v, next;
double fee;
}e[2500005];

void insert(int x, int y, int fee)
{
++idx;
e[idx].v = y, e[idx].fee = log(1 - fee/100.);
}

void spfa()
{
int front = 0, tail = 1, pos;
q[tail] = S;
fill(dis+1, dis+N+1, 0);
dis[S] = log(1.*P);
while (front != tail) {
pos = q[++front];
visit[pos] = 0;
for (int u = head[pos]; u != -1; u = e[u].next) {
if (dis[pos] + e[u].fee - dis[e[u].v] > eps) {
dis[e[u].v] = dis[pos] + e[u].fee;
if (!visit[e[u].v]) {  // spfa中防止多次入队
q[++tail] = e[u].v;
visit[e[u].v] = 1;
}
}
}
}
if (dis[T] == 0) {
puts("IMPOSSIBLE!");
}
else {
printf("%.2lf\n", P - exp(dis[T]));
}
}

int main()
{
int M, y, fee;
while (scanf("%d", &N) == 1) {
memset(visit, 0, sizeof (visit));
idx = -1;
for (int i = 1; i <= N; ++i) {
scanf("%d", &M);
for (int j = 1; j <= M; ++j) {
scanf("%d %d", &y, &fee);
insert(i, y, fee);
}
}
scanf("%d %d %d", &S, &T, &P);
spfa();
}
return 0;
}

09-18 1778

09-08 2239
08-07 68
07-25 75
06-12 1761
02-25 4272
09-17 1809
03-31 8732
12-16 2690
07-27 58
11-21 959
07-25 1548
08-17 3423
12-15 2815
07-17 39
06-28 84
07-22 2115
09-21 5739
09-29