1491: [NOI2007]社交网络 - BZOJ
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的更多相关文章
- BZOJ 1491 [NOI2007]社交网络
1491: [NOI2007]社交网络 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1159 Solved: 660[Submit][Status] ...
- BZOJ 1491: [NOI2007]社交网络( floyd )
floyd...求最短路时顺便求出路径数. 时间复杂度O(N^3) ------------------------------------------------------------------ ...
- 1491: [NOI2007]社交网络
1491: [NOI2007]社交网络 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 881 Solved: 518[Submit][Status] ...
- BZOJ1491:1491: [NOI2007]社交网络
1491: [NOI2007]社交网络 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 2204 Solved: 1175[Submit][Status ...
- 【BZOJ】1491: [NOI2007]社交网络(floyd)
http://www.lydsy.com/JudgeOnline/problem.php?id=1491 囧囧囧...................... 囧1:虽然自己想到做法了,但是操作的时候, ...
- BZOJ 1491: [NOI2007]社交网络(Floyd+暴力乱搞)
题面: https://www.lydsy.com/JudgeOnline/problem.php?id=1491 题解: 先看数据范围,n<=100..欸可以乱搞了 首先因为小学学过的乘法原理 ...
- 1491. [NOI2007]社交网络【最短路计数】
Description 在社交网络(socialnetwork)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题. 在一个社交圈子里有n个人,人与人之间有不同程度的关系.我们将这 ...
- [BZOJ1491][NOI2007]社交网络 floyd
1491: [NOI2007]社交网络 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 2196 Solved: 1170[Submit][Status ...
- 图论(floyd算法):NOI2007 社交网络
[NOI2007] 社交网络 ★★ 输入文件:network1.in 输出文件:network1.out 简单对比 时间限制:1 s 内存限制:128 MB [问题描述] 在社交网络( ...
随机推荐
- 【转】一个高端.NET技术人才的2014年度总结
[转]一个高端.NET技术人才的2014年度总结 本人在一家公司做技术负责人.主要从事的是.net方面的开发与管理,偏重开发. 弹指一挥间,时间飘然而过,转眼又是一年. 回顾2014年,是我人生中最 ...
- Silverlight 独立存储(IsolatedStorageFile)
1.在Web中添加天气服务引用地址 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl 2.在Web中添加Wcf服务接口I ...
- c#的基础入门回顾
定义:.net 是平台 c#是语言 .net 可以做什么:winform (QQ软件 电脑管家软件等 桌面应用程序) . asp.net (淘宝网站,京东网站,当当网站等internet网站) . ...
- kettle的windows安装
1.首先去官网下载安装包,这个安装包在所有平台上是通用的. 2.kettle是java语言开发的,所以需要配置JAVA_HOME 3.解压kettle的安装包 4.配置环境变量,KETTLE_HOME ...
- ngx_http_upstream_module模块学习笔记
ngx_http_upstream_module用于将多个服务器定义成服务器组,而由proxy_pass,fastcgi_pass等指令引用 (1)upstream name {...} 定义一个后 ...
- Hive中的排序语法
ORDER BY hive中的ORDER BY语句和关系数据库中的sql语法相似.他会对查询结果做全局排序,这意味着所有的数据会传送到一个Reduce任务上,这样会导致在大数量的情况下,花费大量时间. ...
- spark概论,补充
基本概念 RDD spark最大的亮点是提出RDD(Resilient Distributed Dataset)的概念,也就是可伸缩的分布式数据集合,本身只读,可恢复.spark本身不做物理储存,通过 ...
- SQL基础篇---基本概念解析
1.数据库database:保存表和其他相关SQL结构容器(一般是一个文件或者一组文件) 2.SQL (Structared Query Language):是一种专门用来与数据库沟通的语言,是一种结 ...
- hdu 5535 Cake 构造+记忆化搜索
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5355 题意:给定n与m,其中1<= n <= 1e5,2 <= m <= 10;问 ...
- QPBOC扩展应用交易流程
1 Q扩展部分数据 增加3个DGI,分别为:A001,8020,9020 9103中增加DF60(9F38中),DF61 增加DF62,DF63 1.1 A001扩展应用配置 DGI 长度 值(示例 ...