QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190461#6763. Triangle Pendantucup-team004WA 1ms4008kbC++202.9kb2023-09-28 22:00:272023-09-28 22:00:28

Judging History

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

  • [2023-09-28 22:00:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4008kb
  • [2023-09-28 22:00:27]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using real = double;

struct Point {
    real x = 0;
    real y = 0;
    real z = 0;
};

Point operator+(const Point &a, const Point &b) {
    return {a.x + b.x, a.y + b.y, a.z + b.z};
}

Point operator-(const Point &a, const Point &b) {
    return {a.x - b.x, a.y - b.y, a.z - b.z};
}

Point operator*(const Point &a, real b) {
    return {a.x * b, a.y * b, a.z * b};
}

Point operator/(const Point &a, real b) {
    return {a.x / b, a.y / b, a.z / b};
}

real length(const Point &a) {
    return std::hypot(a.x, a.y, a.z);
}

Point normalize(const Point &a) {
    real l = length(a);
    return {a.x / l, a.y / l, a.z / l};
}

real getAng(real a, real b, real c) {
    return std::acos((a * a + b * b - c * c) / 2 / a / b);
}

std::ostream &operator<<(std::ostream &os, const Point &a) {
    return os << "(" << a.x << ", " << a.y << ", " << a.z << ")";
}

real dot(const Point &a, const Point &b) {
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

Point cross(const Point &a, const Point &b) {
    return {
        a.y * b.z - a.z * b.y,
        a.z * b.x - a.x * b.z,
        a.x * b.y - a.y * b.x
    };
}

void solve() {
    int x, y, z, a, b, c;
    std::cin >> x >> y >> z >> a >> b >> c;
    
    Point A, B, C, D, G;
    int t = 0;
    while (true) {
        A = {real(0), real(0), real(0)};
        B = {real(c), real(0), real(0)};
        real BAC = getAng(b, c, a);
        C = {b * std::cos(BAC), b * std::sin(BAC), real(0)};
        
        G = (A + B + C) / real(3);
        
        real BAD = getAng(c, x, y);
        Point O1{x * std::cos(BAD), real(0), real(0)};
        real r1 = x * std::sin(BAD);
        Point O2{O1.x, C.y, real(0)};
        real r2 = std::sqrt(z * z - (O1.x - C.x) * (O1.x - C.x));
        real DO1O2 = getAng(r1, O2.y, r2);
        D = {O1.x, r1 * std::cos(DO1O2), r1 * std::sin(DO1O2)};
        
        if (!std::isnan(length(D))) {
            break;
        }
        D = {O1.x, -r1, real(0)};
        if (!std::isnan(length(D)) && length(D - C) <= z && cross(B - D, G - D).z >= 0 && cross(G - D, A - D).z >= 0) {
            break;
        }
        D = A + normalize(A - G) * x;
        if (length(C - D) <= z && length(B - D) <= y) {
            break;
        }
        t++;
        std::swap(a, b);
        std::swap(b, c);
        std::swap(x, y);
        std::swap(y, z);
    }
    
    Point vec = normalize(D - G);
    real hA = dot(vec, A - D);
    real hB = dot(vec, B - D);
    real hC = dot(vec, C - D);
    while (t--) {
        std::swap(hB, hC);
        std::swap(hA, hB);
    }
    
    std::cout << hA << " " << hB << " " << hC << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cout << std::fixed << std::setprecision(10);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4008kb

input:

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

output:

-0.8164965809 -0.8164965809 -0.8164965809
-nan nan nan

result:

wrong output format Expected double, but "-nan" found