VNEMPIRE - Đế chế

An empire is building a network for its own planets. The empire consists of N planets, represented as points in the 3D space. The cost of connecting planet A and planet B is min{ |xA - xB|, |yA - yB|, |zA - zB| } with (xA, yA, zA), (xB, yB, zB) are coordinates of planet A, B in space. The empire is planning to build N - 1 connection and the requirement is that all planets are connected with each other and the cost is minimized.

Input

  • Number of planets N (N < 100001).
  • Next N lines, one line represents one coordiate of a planet.

Output

Only the minimum cost.

Example

 
Input 
5
11 -15 -15
14 -5 -15
-1 -1 -5
10 -4 -1
19 -4 19

Output 
4 


Được gửi lên bởi:Trần Hải Đăng
Ngày:2010-05-03
Thời gian chạy:0.400s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: GOSU NODEJS OBJC PERL6 PYPY RUST SED SQLITE VB.NET
Nguồn bài:COCI 2010 contest 7

hide comments
2021-05-27 17:59:38
Tham khảo: https://vnspoj.github.io/problems/VNEMPIRE
2019-06-04 17:25:59
sort 3 lan thoi sao lai 4 nhi ???
AC
2019-06-02 07:55:53
sai u với v 3 đấm ms ac :(
2019-06-02 05:48:16
(ldv) code ac : https://ideone.com/r2DX9N
2019-05-27 04:34:04
4 sort + dsu = 1 dam AC
From dAt
2018-10-19 14:51:32
kham khảo lời giải:
https://vietcodes.github.io/code/149/index.html

Last edit: 2018-10-19 14:52:18
2018-09-03 16:52:34
nhật hào sạch
2018-04-17 18:44:45
HÚ HÀ
2017-07-16 07:42:02
Em sort tận 4 lần các bác ạ :)
2017-05-21 12:50:31
from Dinh Truong Lam(CTN)
sort 4 lần :))
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.