QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421952#6763. Triangle Pendant36champWA 0ms3924kbC++204.1kb2024-05-26 12:20:132024-05-26 12:20:13

Judging History

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

  • [2024-05-26 12:20:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3924kb
  • [2024-05-26 12:20:13]
  • 提交

answer

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

using namespace std;

double eps = 1e-9;

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);
}

double angle(point A, point B)
{
    return acos(dot(A, B) / norm(A) / norm(B));
}

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";
        cout << dist(C, D) << " " << lc << "\n";

        point M = (A + B + C) / 3;
        double theta = angle(A - D, B - D);
        double theta1 = angle(M - D, B - D);
        double theta2 = angle(A - D, M - D);

        cout << abs(theta - theta1 - theta2) << "\n";

        if(abs(theta - theta1 - theta2) < eps && dist(C, D) < lc + eps)
        {
            //cout << "HANG AB " << 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);
        }
    }

    //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();
    }
}
/*
1
13 5 1000 20 12 12
*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3924kb

input:

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

output:

(0.000000000000,0.000000000000,0.000000000000) (1.000000000000,0.000000000000,0.000000000000) (0.500000000000,0.866025403784,0.000000000000) (0.500000000000,-0.866025403784,0.000000000000)
1.732050807569 1.000000000000
0.000000000000
(0.000000000000,0.000000000000,0.000000000000) (1.000000000000,0.0...

result:

wrong output format Expected double, but "(0.000000000000,0.000000000000,0.000000000000)" found