QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421927#6763. Triangle Pendant36champWA 3ms3908kbC++203.8kb2024-05-26 11:22:442024-05-26 11:22:44

Judging History

你现在查看的是最新测评结果

  • [2024-05-26 11:22:44]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3908kb
  • [2024-05-26 11:22:44]
  • 提交

answer

#include <bits/stdc++.h>
#define double long double
#define pb push_back

using namespace std;

double eps = -1e-4;

struct point{
    double x, y, z;

    point operator+ (point B) {return {x + B.x, y + B.y, z + B.z};}
    point operator- (point B) {return {x - B.x, y - B.y, z - B.z};}
    point operator* (double d) {return {x * d, y * d, z * d};}
    point operator/ (double d) {return {x / d, y / d, z / d};}
};

ostream& operator<<(ostream& os, point p)
{
    return os << "("<< p.x << "," << p.y << "," << p.z << ")";
}

double dot(point A, point B)
{
    return A.x * B.x + A.y * B.y + A.z * B.z;
}

double norm(point P)
{
    return sqrt(dot(P, P));
}

double sq(point A, point B)
{
    return dot(A - B, A - B);
}

double dist(point A, point B)
{
    return sqrt(sq(A, B));
}

point normalize(point P)
{
    return P / norm(P);
}

void cycle(double &a, double &b, double &c)
{
    double x = a;
    a = b;
    b = c;
    c = x;
}

void solve()
{
    double la, lb, lc, a, b, c;
    cin >> la >> lb >> lc >> a >> b >> c;

    for(int i=0; i<3; i++)
    {
        //Hang by C
        point A{0, 0, 0}, B{c, 0, 0}, C, D, M;
        C = {(c*c+b*b-a*a)/(2*c), 0, 0};
        C.y = sqrt(b * b - C.x * C.x);
        M = (A + B + C) / 3;
        D = C + normalize(C - M) * lc;

        if(dist(A, D) < la + eps && dist(B, D) < lb + eps)
        {
            //cout << "HANG C " << i << "\n";
            point X = normalize(M - D);
            double ha = - dot(A - D, X);
            double hb = - dot(B - D, X);
            double hc = - dot(C - D, X);

            if(i==0) cout << ha << " " << hb << " " << hc << "\n";
            if(i==1) cout << hc << " " << ha << " " << hb << "\n";
            if(i==2) cout << hb << " " << hc << " " << ha << "\n";
            return;
        }
        else
        {
            cycle(a, b, c);
            cycle(la, lb, lc);
        }
    }

    for(int i=0; i<3; i++)
    {
        //Hang by AB
        point A{0, 0, 0}, B{c, 0, 0}, C, D;
        C = {(c*c+b*b-a*a)/(2*c), 0, 0};
        C.y = sqrt(b * b - C.x * C.x);
        D = {(c*c+la*la-lb*lb)/(2*c), 0, 0};
        D.y = -sqrt(la*la - D.x * D.x);

        //cout << A << " " << B << " " << C << " " << D << "\n";

        if(dist(C, D) < lc + eps)
        {
            //cout << "HANG AB " << i << "\n";
            point M = (A + B + C) / 3;
            point X = normalize(M - D);
            double ha = - dot(A - D, X);
            double hb = - dot(B - D, X);
            double hc = - dot(C - D, X);

            if(i==0) cout << ha << " " << hb << " " << hc << "\n";
            if(i==1) cout << hc << " " << ha << " " << hb << "\n";
            if(i==2) cout << hb << " " << hc << " " << ha << "\n";
            return;
        }
        else
        {
            cycle(a, b, c);
            cycle(la, lb, lc);
        }
    }

    //Tetrahedron
    point A{0, 0, 0}, B{c, 0, 0}, C, D;
    C = {(c*c+b*b-a*a)/(2*c), 0, 0};
    C.y = sqrt(b * b - C.x * C.x);
    D.x = (c * c + la * la - lb * lb) / (2 * c);
    D.y = (dot(C, C) + la*la - lc*lc - 2 * C.x * D.x) / (2 * C.y);
    D.z = sqrt(la * la - D.x * D.x - D.y * D.y);

    point M = (A + B + C) / 3;
    point X = normalize(M - D);
    double ha = - dot(A - D, X);
    double hb = - dot(B - D, X);
    double hc = - dot(C - D, X);

    //cout << A << " " << B << " " << C << " " << D << " " << M << "\n";
    //cout << A - D << "." << X << " = " << dot(A - D, X) << "\n";
    cout << ha << " " << hb << " " << hc << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(12);

	int T;
	cin >> T;
	while(T-->0)
    {
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

input:

2
1 1 1 1 1 1
2 3 3 1 1 1

output:

-0.816496580928 -0.816496580928 -0.816496580928
-2.000000000000 -2.866025403784 -2.866025403784

result:

ok 6 numbers

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3908kb

input:

1000
21 2 14 12 13 4
29 19 13 15 10 17
29 24 15 29 24 23
29 17 30 18 9 25
27 24 30 16 4 15
28 13 17 12 21 16
16 22 10 22 15 8
15 23 24 23 27 13
26 3 27 15 16 17
5 8 20 17 6 12
24 14 13 15 19 13
27 22 18 18 23 30
22 18 14 11 29 28
7 13 22 22 17 11
19 9 16 22 20 17
21 14 20 6 29 25
20 10 19 9 27 27
17...

output:

-2.935856727587 -2.000000000000 -13.352348999858
-22.146476218003 -16.076204705477 -12.241826659011
-28.027431433360 -18.318582636183 -8.243362186282
-27.266119651334 -13.159319584326 -26.882525397693
-26.534933366926 -22.066632132649 -29.616079568530
-26.967804477492 -12.557669395974 -14.1867221345...

result:

wrong answer 382nd numbers differ - expected: '-24.86301', found: '-24.27354', error = '0.02371'