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 [问题描述] 在社交网络( ...
随机推荐
- jquery 仿手机屏幕切换界面效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Objective-C中的self和super
1.有过面向对象的人知道,self相当于this,super相当于调用父类的方法 2.self是类的隐藏的参数,指向当前调用方法的类,另一个隐藏参数是_cmd,代表当前类方法的selector. su ...
- c语言学习的第10天
#include <stdio.h> int main() { int many; printf("你想看几次?"); scanf("%d",&am ...
- 选择两个字段时distinct位置的影响
当选择两个字段时,例如:"select XX1, XX2 from tb; ",那么将distinct放在前一个字段XX1之前和放在后一个字段XX2之前,结果有什么不同呢? 先说结 ...
- 通过URLHttpConnection方式连接网络步骤,获取位图为例
要注意的是:访问网络不能直接放在主线程,要放在另外一个线程里面,如果放在主线程会报android.os.NetworkOnMainThreadException错误1 public Bitmap ge ...
- windows下编译lua源码
所有的lua源码都放在了 src 文件夹下,当然,不同的lua版本目录结构有可能不一样,但是都会有 src 这个文件夹,只有这个才是我们编译必须的.而且lua越做越精简了,5.1的版本里面还有一些te ...
- delphi android 中 Toast 的实现(老外写的UNIT)
unit Android.JNI.Toast; // Java bridge class imported by hand by Brian Long (http://blong.com)interf ...
- Python学习教程(learning Python)--2.3 Python自定义函数传参函数设计
Python里自定义子函数时,可以在调用时携带一些参数到子函数里去处理.具体用法结构如下: def func(arguments): statement statement etc. 定义子函数一定要 ...
- VC下的人人对弈五子棋(dos)
#include"stdio.h"#include"stdlib.h"#include"string.h"#include "io ...
- 在Linux下JDK1.4.2安装报错的解决方法
JDK1.4.2的安装 Do you agree to the above license terms? [yes or no] yes Unpacking... tail: cann ...