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. js冒泡事件之之之

    console.log("event.target="+event.target); console.log("event.target="+event.tar ...

  2. scribe日志分析工具安装

    系统CentOS6.2 x86_64 1.yum安装gcc,flex,m4,python/python-devel,ruby,libevent/libevent-devel,openssl/opens ...

  3. ASP.NET中Server对象的几个方法

    HtmlDecode 已重载. 对已被编码以消除无效 HTML 字符的字符串进行解码.HtmlEncode 已重载. 对要在浏览器中显示的字符串进行编码.MapPath 返回与 Web 服务器上的指定 ...

  4. Oracle 11gR2 RAC修改SCAN IP

    一.查看当前环境: # grid用户 检查scan-ip地址的配置 [grid@node1 ~]$ srvctl config scan SCAN name: scan-cluster.com, Ne ...

  5. python 关于 ImportError: No module named 的问题

    转载自:http://my.oschina.net/leejun2005/blog/109679 今天在 centos 下安装 python setup.py install 时报错:ImportEr ...

  6. DB2中ixf文件的导入导出

    1. 导出数据 语法:EXPORT TO <文件路径>/文件名.IXF OF IXF SELECT * FROM 表名   2. 导入数据 语法:db2 IMPORT FROM <路 ...

  7. golang初试:坑爷的

    用Golang与perl脚本比较, 初想至多差一倍吧...结果可不是一般的坑爹, 简直就是坑爷了. Perl脚本 #!/bin/bash source /etc/profile; function e ...

  8. Swift的一些基础内容

    //①判断字符串是否为空的方法 isEmpty var str:String = "www.baidu.com" if str.isEmpty { print("空字符串 ...

  9. 为什么学习Python

    因为做iOS开发的,之前一直用OC,但是突然有一天苹果说出Swift,但是那时候的Swift真的是Bug多多,语法都不固定,所以只是大致看了看,而一年多之后,Swift已经发布2.0了,语言也相对稳定 ...

  10. ExtJs桌面组件(DeskTop)

    在desktop\js目录中包含了5个js文件,这5个js文件如下: 还有css样式表:desktop.css,图片素材 在这5个js文件中封装了用于模拟桌面的类,这些类如下: Ext.ux.Star ...