Logo
(追記) (追記ここまで)

18906번 - Minimal Variance Tree 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB1264314.286%

문제

Sophie learned today that the notion of variance can be extended to edge-weighted trees: given a tree with edges $E$ this is a sum (over $E$) of squared differences between the weights of the edges and the mean weight of the edges. She was able to come up with a formula for that: if $w_e$ denotes the weight of the edge $e$ then the variance of the tree is

\[\sum_{e \in E} \left( w_e - S_T \right)^2 \mbox{, where } S_T = \sum_{e \in E} \frac{w_e}{|E|}\enspace .\]

Sophie wonders, whether for a given multigraph she can compute its spanning tree with the smallest variance. Help her in this task.

입력

First line of the input contains two positive integers $n$ and $m$ $(2 \leq n \leq 10,000円,ドル 1ドル \leq m \leq 10,000円),ドル denoting the number of vertices and edges of the graph. Each of the following $m$ lines contains three positive integers $a_i,ドル $b_i$ and $w_i$ $(1 \leq a, b \leq n,ドル $a \neq b,ドル 1ドル \leq w \leq 100,000円),ドル this is the description of the $i$th edge, which connects the vertices $a_i$ and $b_i$ and has the weight $w_i$.

The described graph is connected, it can have many edges between any two vertices, those edges can have different weights.

출력

You should one real number: minimal value of variance of a spanning tree of the given graph. The answer is accepted if the relative or absolute error is at most 10ドル^{-6}$.

제한

예제 입력 1

4 6
1 2 3
2 3 9
3 4 7
1 3 5
1 3 6
4 1 2

예제 출력 1

4.666666667

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2017 M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /