Description

Input

Output
输出文件包括n 行,每行一个实数,精确到小数点后3 位。第i 行的实数表 示结点i 在社交网络中的重要程度。
Sample Input
4 4
1 2 1
2 3 1
3 4 1
4 1 1
Sample Output
1.000
1.000
1.000
1.000
HINT


为1

其实floyd已经够了,我这sb没想到,TM想了半天想出一个拓扑排序的,还用了floyd预处理最短路,而且还下了数据和标程才突然想起来,我TM没拓扑排序for个屁啊(最后写出来pascal第一,当然是因为floyd做了太多没用的事啦)

 const
maxn=;
maxm=;
var
first,d:array[..maxn]of longint;
last,next,w:array[..maxm*]of longint;
f:array[..maxn,..maxn]of longint;
ans,a:array[..maxn]of double;
s:array[..maxn]of int64;
n,m,tot:longint; procedure insert(x,y,z:longint);
begin
inc(tot);
last[tot]:=y;
next[tot]:=first[x];
first[x]:=tot;
w[tot]:=z;
end; var
q:array[..maxn]of longint;
l,r:longint; procedure work(x:longint);
var
i:longint;
begin
for i:= to n do s[i]:=;
for i:= to n do a[i]:=;
for i:= to n do d[i]:=;
for l:= to n do
begin
i:=first[l];
while i<> do
begin
if f[x,l]+w[i]=f[x,last[i]] then inc(d[last[i]]);
i:=next[i];
end;
end;
l:=;r:=;q[]:=x;s[x]:=;
while l<=r do
begin
i:=first[q[l]];
while i<> do
begin
if f[x,q[l]]+w[i]=f[x,last[i]] then
begin
dec(d[last[i]]);
if d[last[i]]= then
begin
inc(r);
q[r]:=last[i];
end;
inc(s[last[i]],s[q[l]]);
end;
i:=next[i];
end;
inc(l);
end;
for l:=n downto do
begin
i:=first[q[l]];
while i<> do
begin
if f[x,q[l]]+w[i]=f[x,last[i]] then a[q[l]]:=a[q[l]]+a[last[i]]+/s[last[i]];
i:=next[i];
end;
end;
for i:= to n do ans[i]:=ans[i]+a[i]*s[i];
end; procedure main;
var
i,j,k,x,y,z:longint;
begin
read(n,m);
fillchar(f,sizeof(f),);
for i:= to n do f[i,i]:=;
for i:= to m do
begin
read(x,y,z);
insert(x,y,z);
insert(y,x,z);
if z<f[x,y] then
begin
f[x,y]:=z;
f[y,x]:=z;
end;
end;
for k:= to n do
for i:= to n do
for j:= to n do
if f[i,k]+f[k,j]<f[i,j] then f[i,j]:=f[i,k]+f[k,j];
for i:= to n do work(i);
for i:= to n do writeln(ans[i]::);
end; begin
main;
end.

1491: [NOI2007]社交网络 - BZOJ的更多相关文章

  1. BZOJ 1491 [NOI2007]社交网络

    1491: [NOI2007]社交网络 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1159  Solved: 660[Submit][Status] ...

  2. BZOJ 1491: [NOI2007]社交网络( floyd )

    floyd...求最短路时顺便求出路径数. 时间复杂度O(N^3) ------------------------------------------------------------------ ...

  3. 1491: [NOI2007]社交网络

    1491: [NOI2007]社交网络 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 881  Solved: 518[Submit][Status] ...

  4. BZOJ1491:1491: [NOI2007]社交网络

    1491: [NOI2007]社交网络 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 2204  Solved: 1175[Submit][Status ...

  5. 【BZOJ】1491: [NOI2007]社交网络(floyd)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1491 囧囧囧...................... 囧1:虽然自己想到做法了,但是操作的时候, ...

  6. BZOJ 1491: [NOI2007]社交网络(Floyd+暴力乱搞)

    题面: https://www.lydsy.com/JudgeOnline/problem.php?id=1491 题解: 先看数据范围,n<=100..欸可以乱搞了 首先因为小学学过的乘法原理 ...

  7. 1491. [NOI2007]社交网络【最短路计数】

    Description 在社交网络(socialnetwork)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题. 在一个社交圈子里有n个人,人与人之间有不同程度的关系.我们将这 ...

  8. [BZOJ1491][NOI2007]社交网络 floyd

    1491: [NOI2007]社交网络 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 2196  Solved: 1170[Submit][Status ...

  9. 图论(floyd算法):NOI2007 社交网络

    [NOI2007] 社交网络 ★★   输入文件:network1.in   输出文件:network1.out   简单对比 时间限制:1 s   内存限制:128 MB [问题描述] 在社交网络( ...

随机推荐

  1. css3内处理

    1.插入文字:content属性:          p:after{content:"内容"}          p:before{content:"内容"} ...

  2. 后缀为inc的是什么文件?C#中如何包含inc文件?

    在项目Web页面文件中,发现这么一句话: <!-- 页面字符集设置 begin--><!-- #INCLUDE FILE="http://www.cnblogs.com/C ...

  3. Spark自定义分区(Partitioner)

    我们都知道Spark内部提供了HashPartitioner和RangePartitioner两种分区策略,这两种分区策略在很多情况下都适合我们的场景.但是有些情况下,Spark内部不能符合咱们的需求 ...

  4. Mac 安装 Tomcat

    默认mac已经安装好java jdk-----/Library/Java/JavaVirtualMachines 1. http://tomcat.apache.org/download-70.cgi ...

  5. php读取excel文件 更新修改excel

    php读取excel文件示例,还有更新修改功能. 代码: //模板存放目录 $dir = $DOCUMENT_ROOT.'/backoffice/admin/oemcheck/'; $template ...

  6. (原创)Windows8下安装配置WAMP

    Windows8下安装配置WAMP        2013/12/28 最近这段时间一直在研究linuxshell编程,虽然还是初级水平,但比之前有了不小的进度,但是shell的命令很多,很难在短时间 ...

  7. 一个php函数,能够遍历一个文件夹下的所有文件和子文件夹

    <?phpfunction my_scandir($dir){    $files=array();    if(is_dir($dir))     {        if($handle=op ...

  8. p ython笔记第一天

    一.Linux基础 - 计算机以及日后我们开发的程序防止的服务器的简单操作 二.Python开发 http://www.cnblogs.com/wupeiqi/articles/5433893.htm ...

  9. 苏泊尔借助微软CRM提升客户满意度

    企业背景 作为中国最大.全球第二的炊具研发制造商和中国小家电领先品牌,品质和创新一是苏泊尔矢志追求的企业理念,从火红点无油烟锅的发明到能做柴火饭的球釜IH饭煲的面世,苏泊尔用产品的创新和品质的承诺,不 ...

  10. core java 5~6(OOP & 高级语言特征)

    MODULE 5 OOP 面向对象程序设计--------------------------------------------------------Object Oriented Program ...