// OBčh2009 Day3 G : Strange Couple #include #include #include #include #include using namespace std; class Edge{ public: int p, q, cost; Edge(int p, int q, int cost) : p(p), q(q), cost(cost) {} bool operator < (const Edge &e) const { return cost > e.cost; } }; int main(){ int n, s, t; while(cin >> n >> s >> t, n){ s--; t--; int cst[100][100]; int sign[100], out[100]; for(int i=0;i> sign[i]; vector< vector > graph(n); memset(out,0,sizeof(out)); for(int i=0;i> cst[i][j]; if(cst[i][j]){ out[i]++; graph[i].push_back(Edge(i,j,cst[i][j])); } } } vector dist(n,-1); priority_queue qu; qu.push(Edge(-2,t,0)); while(!qu.empty()){ Edge e = qu.top(); qu.pop(); int pos = e.q, ccost = e.cost; if(!(dist[pos]<0)) continue; dist[pos] = ccost; for(int i=0;i-1&&dist[j]>-1&&dist[i]==dist[j]+cst[i][j]) cnt++; } for(int j=0;j-1&&dist[j]>-1&&dist[i]==dist[j]+cst[i][j]){ a[i][j] -= 1.0/cnt; b[i] += (double)cst[i][j]/cnt; } } } else { a[i][i] = 1; for(int j=0;jabs(a[pivot][i])) pivot = j; for(int j=0;j=0;i--){ for(int j=0;j