求助P5143
  • 板块学术版
  • 楼主Prolystic
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/5/14 09:47
  • 上次更新2023/10/23 15:49:03
查看原帖
求助P5143
695863
Prolystic楼主2023/5/14 09:47

RT,本地测能过,交上去全WA

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 50005;
int N;
double sum;
struct point{
    int x, y, z;
    bool operator <(const point &other)const{
        return z < other.z;
    }
}mp[MAXN];
double EuclidDis(point a, point b){
    return sqrt((a.y - b.y) * (a.y - b.y) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z));
}
bool pointSort(point a, point b){
    return a.z > b.z;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> mp[i].x >> mp[i].y >> mp[i].z;
    sort(mp + 1, mp + 1 + N);
    for(int i = 2; i <= N; i++) sum += EuclidDis(mp[i], mp[i - 1]);
    cout << fixed << setprecision(3) << sum << '\n';
    return 0;
}
2023/5/14 09:47
加载中...