"Bzoj 1491" [NOI2007] Social network

Source: Internet
Author: User

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


See the data range, obviously floydmap[i][j] represents the shortest circuit of i-->j, A[i][j] represents the number of scenarios that represent the least-shorted scheme from I to J, which is zeroed when the minimum path is changed
1#include <cstdio>2#include <cstring>3 using namespacestd;4 Const intn= the, inf=1000000000;5 DoubleA[n][n];6 intn,m,u,v;7 Doubleans[n],map[n][n],w;8 intMain () {9scanf"%d%d",&n,&m);Ten      for(intI=1; i<=n;i++) One          for(intj=1; j<=n;j++) map[i][j]= (inf+0.0); A      for(intI=1; i<=m;i++){ -scanf"%D%D%LF",&u,&v,&W); -Map[u][v]=map[v][u]= (w+0.0); thea[u][v]=a[v][u]=1; -     } -      for(intk=1; k<=n;k++) -          for(intI=1; i<=n;i++) +              for(intj=1; j<=n;j++){ -                 if(Map[i][j]>map[i][k]+map[k][j]) map[i][j]=map[i][k]+map[k][j],a[i][j]=0;; +                 if(map[i][j]== (Map[i][k]+map[k][j])) a[i][j]+=a[i][k]*A[k][j]; A             } at       for(intI=1; i<=n;i++) a[i][i]=0; -      for(intk=1; k<=n;k++) -          for(intI=1; i<=n;i++) -              for(intj=1; j<=n;j++){ -                 if(map[i][j]== (map[i][k]+map[k][j]) &&a[i][j]>0) -ans[k]+=a[i][k]*a[k][j]/(a[i][j]+0.0);  in             } -      for(intI=1; i<=n;i++) printf ("%.3lf\n", Ans[i]);  to}

"Bzoj 1491" [NOI2007] Social network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.