样例能过测试点全部WA
查看原帖
样例能过测试点全部WA
535134
12wasd3456zxc楼主2021/7/31 21:51

样例能过测试点全部WA!!

AWWW

测试记录详情



#include <bits/stdc++.h>

using namespace std;


struct coord
{
    int X, Y, Z;
    coord()
    {
        X = 0; Y = 0; Z = 0;
    }
    const bool operator<(const coord& c2)const
    {
        return this->Z < c2.Z;
    }
};


int main()
{
    int N = 0;
    scanf("%d", &N);
    int a = 0, b = 0, c = 0;
    coord* points = new coord[N + 4]();
    for (int i = 1; i <= N; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        points[i].X = a, points[i].Y = b, points[i].Z = c;
    }
    sort(points, points + N);
    double ans = 0.0f;

    for (int i = 1; i < N; i++) {
        ans += hypot(hypot(points[i].X - points[i + 1].X, points[i].Y - points[i + 1].Y), points[i].Z - points[i + 1].Z);
    }

    printf("%.3f", ans);
    return 0;
}
2021/7/31 21:51
加载中...