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. [leetcode]_Search Insert Position

    题目:查找元素target插入一个数组中的位置. 代码: public int searchInsert(int[] A, int target) { int len = A.length; int ...

  2. 反编译工具(.NET Reflector )

    1.下载安装原程序,然后运行 Reflector.exe 2.运行注册机,点击 Generate 获得序列号 3.把序列号填写到 Reflector 软件上4.断开网络,点击 Activate 激活( ...

  3. redis 入门

    1.命令行工具 在windows上巧命令行指令,实在是令人痛苦,本人实在是受不了windows下cmd的笨,powershell的蠢,只能换一个了. 介绍一款cmd工具cmder(github上开源) ...

  4. WordPress 主题开发 - (四) 创建WordPress的主题HTML结构 待翻译

    Now we're starting to get into the real meat of WordPress Theme development: coding the HTML structu ...

  5. recurse_array_change_key_case()递规返回字符串键名全为小写或大写的数组

    //递归返回字符串键名全为小写或大写的数组function recurse_array_change_key_case(&$input, $case = CASE_LOWER){    if( ...

  6. C++ string 转 char*

    string 转到 char* char name[20]; string sname=GatherName[n]; strcpy(name,sname.c_str());

  7. Struts2中的namespace使用

    namespace一般在项目比较复杂的情况下使用较好. 在struts2的项目中,namespace主要在以下环境中常使用: 1. 在配置文件中(struts.xml)以及被它包含的XX.xml文件中 ...

  8. PHP JS HTML ASP页面跳转代码 延时跳转代码

    1.PHP延时跳转代码 //跳转到浏览界面 header("Refresh:1;url=machine_list.php"); //不延时 <?php header(&quo ...

  9. Javascript 插件统一的实现步骤

    步骤: // 1. 定义立即调用的函数 +function($){ "use strict"; //使用严格模式ES5支持 //后续步骤 // 2. xx 插件类及原型方法的定义 ...

  10. AppCan教你从零开始做开发

    经常收到类似这样的提问:新手开发APP,要怎么学?我有满屏幕的文档和视频,然而并没有什么卵用,因为我不知道该从哪看起……今天的主要内容是教大家,如何在AppCan移动平台创建应用,引擎插件选择.证书管 ...