Problem:
Problem H: Winter Bells

The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged near windows for children.

The sleigh she is on departs from a big christmas tree on the fringe of the city. Miracle power that the christmas tree spread over the sky like a web and form a paths that the sleigh can go on. Since the paths with thicker miracle power is easier to go, these paths can be expressed as undirected weighted graph.

Derivering the present is very strict about time. When it begins dawning the miracle power rapidly weakens and Santa Clause can not continue derivering any more. Her pride as a Santa Clause never excuses such a thing, so she have to finish derivering before dawning.

The sleigh a reindeer pulls departs from christmas tree (which corresponds to 0th node), and go across the city to the opposite fringe (n-1 th node) along the shortest path. Santa Clause create presents from the miracle power and shoot them from the sleigh the reindeer pulls at his full power. If there are two or more shortest paths, the reindeer selects one of all shortest paths with equal probability and go along it.

By the way, in this city there are p children that wish to see Santa Clause and are looking up the starlit sky from their home. Above the i-th child's home there is a cross point of the miracle power that corresponds to c[i]-th node of the graph. The child can see Santa Clause if (and only if) Santa Clause go through the node.

Please find the probability that each child can see Santa Clause.

Input

Input consists of several datasets.

The first line of each dataset contains three integers n, m, p, which means the number of nodes and edges of the graph, and the number of the children. Each node are numbered 0 to n-1.

Following m lines contains information about edges. Each line has three integers. The first two integers means nodes on two endpoints of the edge. The third one is weight of the edge.

Next p lines represent c[i] respectively.

Input terminates when n = m = p = 0.

Output

For each dataset, output p decimal values in same order as input. Write a blank line after that.

You may output any number of digit and may contain an error less than 1.0e-6.

Constraints

3 ≤ n ≤ 100

There are no parallel edges and a edge whose end points are identical.

0 < weight of the edge < 10000

Sample Input

3 2 1
0 1 2
1 2 3
1
4 5 2
0 1 1
0 2 1
1 2 1
1 3 1
2 3 1
1
2
0 0 0

Output for the Sample Input

1.00000000

0.50000000
0.50000000

Solution in C++ (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

#define MAX 114
#define INF 1e9
typedef pair<int,int> pii;

struct Edge{
    int to,cost;
    Edge(int to,int cost) :
        to(to),cost(cost) {}
};

double dp[MAX];
bool visited[MAX];
vector<Edge> G[MAX];

void dfs(int v,vector<int> &d){
    if(visited[v]) return;
    visited[v] = 1;
    int cnt = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        Edge e = G[v][i];
        if(d[v]-d[e.to] == e.cost){
            cnt++;
        }
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        Edge e = G[v][i];
        if(d[v]-d[e.to] == e.cost){
            dfs(e.to,d);
            dp[e.to] *= dp[v]*cnt; 
        }
    }
}

void init(){
    for(int i = 0 ; i < MAX ; i++){
        G[i].clear();
    }
}

int main(){
    int n,m,p,a,b,c;
    while(cin >> n >> m >> p, n){
        init();
        for(int i = 0 ; i < m ; i++){
            cin >> a >> b >> c;
            G[a].push_back(Edge(b,c));
            G[b].push_back(Edge(a,c));
        }
        priority_queue<pii,vector<pii>,greater<pii> > Q;
        Q.push(pii(0,0));
        vector<int> d(n,INF); d[0] = 0;
        while(!Q.empty()){
            pii p = Q.top(); Q.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(int i = 0 ; i < (int)G[v].size() ; i++){
                Edge e = G[v][i];
                if(d[v] + e.cost < d[e.to]){
                    d[e.to] = d[v] + e.cost;
                    Q.push(pii(d[e.to],e.to));
                }
            }
        }
        memset(visited,0,sizeof(visited));
        fill(dp,dp+MAX,1);
        dfs(n-1,d);
        for(int i = 0 ; i < n ; i++){
            if(!visited[i]) dp[i] = 0;
        }
        for(int i = 0 ; i < p ; i++){
            cin >> c;
            if(dp[c] == 0){
                printf("%.12f\n",0.0);
            }else{
                printf("%.12f\n",1./dp[c]);
            }
        }
        cout << endl;
    }
    return 0;
}