1491: [NOI2007] Social network time limit:10 Sec Memory limit:64 MB
submit:1159 solved:660
[Submit] [Status] [Discuss] The Descriptioninputoutput output file consists of n rows, one real number per line, and 3 digits after the decimal point. The real number on line I indicates how important node I is in social networks. Sample Input4 4
1 2 1
2 3 1
3 4 1
4 1 1Sample Output1.000
1.000
1.000
1.000HINT
is 1
Source
Zheng said, the simplest of the shortest short-circuit count it.
1 /*=============================================================================2 * 3 * Author:crt_164 * 5 * Last modified:2015-08-26 19:106 * 7 * Category: Graph theory Shortest Way8 * 9 /*=============================================================================*/Ten One#include <iostream> A#include <cstdio> -#include <cmath> -#include <algorithm> the#include <stack> -#include <queue> -#include <cstring> - #definePau Putchar (") + #defineENT puts (""); - #defineMSE (A, B) memset (A,b,sizeof (a)) + #defineren (x) for (TED*E=FCH[X];E;E=E->NXT) A #defineRep (i,s,t) for (int i=s,__=t;i<=__;i++) at #defineDwn (i,s,t) for (int i=s,__=t;i>=__;i--) - using namespacestd; - Const intmaxn= -+Ten, maxm=4500+Ten, inf=1e9; - intD[maxn][maxn],n,m;Long LongF[MAXN][MAXN]; -InlineintRead () { - intx=0;BOOLsig=true;CharCh=GetChar (); in for(;! IsDigit (CH); Ch=getchar ())if(ch=='-') sig=false; - for(; isdigit (ch); Ch=getchar ()) x=Ten*x+ch-'0';returnsig?x:-x; to } +InlinevoidWriteintx) { - if(x==0) {Putchar ('0');return;}if(x<0) Putchar ('-'), x=-x; the intlen=0;Static intbuf[ -]; while(x) buf[len++]=x%Ten, x/=Ten; * for(inti=len-1; i>=0; i--) Putchar (buf[i]+'0');return; $ }Panax Notoginseng intMain () { -N=read (); M=read ();intx, y; theRep (I,1, N) Rep (J,1, n) d[i][j]=inf;rep (i,1, N) d[i][i]=0; +Rep (I,1, m) X=read (), Y=read (), d[x][y]=d[y][x]=read (); ARep (I,1, N) Rep (J,1, N) f[i][j]=1; theRep (K,1, N) Rep (I,1, N) Rep (J,1, N)if(i^j) && (j^k) && (k^i)) { + if(d[i][j]>d[i][k]+D[k][j]) { -d[i][j]=d[i][k]+D[k][j]; $f[i][j]=f[i][k]*F[k][j]; $ } - Else if(D[i][j]==d[i][k]+d[k][j]) f[i][j]+=f[i][k]*F[k][j]; - } the DoubleAns[maxn];mse (ans,0.0); -Rep (K,1, N) Rep (I,1, N) Rep (J,1, N)if(i^j) && (j^k) && (k^i) && (d[i][j]==d[i][k]+D[k][j])) {Wuyians[k]+= (Double) f[i][k]* (Double) f[k][j]/(Double) f[i][j]; the}rep (I,1, N) printf ("%.3lf\n", Ans[i]); - Wu return 0; -}
Bzoj 1491 [NOI2007] Social network