Konjac Konjac is the No. 500 AC of the question 233
Yarn, at one glance it looks very high-end, there is a complex formula ...
Later found ... Is... Floyd Water Problem
D[I][J] represents the shortest distance between I, J, Cnt[i][j] represents the shortest distance between I and J
Then use the multiplication principle to update cnt[i][j] can
1 /**************************************************************2 problem:14913 User:rausen4 language:c++5 result:accepted6 time:104 Ms7 memory:936 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <cstring> A - using namespacestd; -typedefLong Longll; thetypedefDoubleLF; - Const intN = the; - - intN, M; + intD[n][n]; - ll Cnt[n][n]; + lf ans; A atInlineintRead () { - intx =0, SGN =1; - CharCH =GetChar (); - while(Ch <'0'||'9'<ch) { - if(ch = ='-') SGN =-1; -CH =GetChar (); in } - while('0'<= CH && Ch <='9') { tox = x *Ten+ CH-'0'; +CH =GetChar (); - } the returnSGN *x; * } $ Panax Notoginseng intMain () { - intI, J, K, X, Y, Z; then = Read (), M =read (); +memset (D,127/3,sizeof(d)); A for(i =1; I <= m; ++i) { thex = Read (), y = read (), z =read (); +D[x][y] = d[y][x] =Z; -Cnt[x][y] = cnt[y][x] =1; $ } $ for(k =1; K <= N; ++k) - for(i =1; I <= N; ++i)if(I! =k) - for(j =1; J <= N; ++J)if(J! = i && J! =k) the if(D[i][j] > D[i][k] +D[k][j]) -D[I][J] = D[i][k] +D[k][j],WuyiCNT[I][J] = cnt[i][k] *Cnt[k][j]; the Else if(D[i][j] = = D[i][k] +D[k][j]) -CNT[I][J] + = cnt[i][k] *Cnt[k][j]; Wu for(k =1; K <= N; ++k) { -Ans =0; About for(i =1; I <= N; ++i)if(I! =k) $ for(j =1; J <= N; ++J)if(J! = i && J! =k) - if(D[i][j] = = D[i][k] +D[k][j]) -Ans + = (LF) (cnt[i][k] * cnt[k][j])/Cnt[i][j]; -printf"%.3lf\n", ans); A } + return 0; the}
View Code
BZOJ1491 [NOI2007] Social network