0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 10:48:48 +00:00
OI-codes/Luogu/P5143/P5143.cpp

38 lines
622 B
C++
Raw Normal View History

2020-09-24 11:36:41 +00:00
// R38821808
#include <bits/stdc++.h>
using namespace std;
struct node {
int x, y, z;
node() {
x = y = z = 0;
}
};
double ed(node a, node b) {
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2));
}
bool cmp(node a, node b) {
return a.z <= b.z;
}
int main() {
int n;
node a[50005];
double ans = 0.000;
scanf("%d", &n);
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
2020-09-24 11:36:41 +00:00
scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
}
2021-11-19 09:01:13 +00:00
sort(a, a + n, cmp);
for (int i = 1; i < n; i++) {
ans += ed(a[i - 1], a[i]);
2020-09-24 11:36:41 +00:00
}
printf("%.3lf", ans);
return 0;
}