QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190463#6763. Triangle Pendantucup-team004AC ✓2ms4384kbC++203.0kb2023-09-28 22:03:152023-09-28 22:03:15

Judging History

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

  • [2023-09-28 22:03:15]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:4384kb
  • [2023-09-28 22:03:15]
  • 提交

answer

#pragma GCC optimize("O2")
#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: 100
Accepted
time: 0ms
memory: 4184kb

input:

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

output:

-0.8164965809 -0.8164965809 -0.8164965809
-2.0000000000 -2.8660254038 -2.8660254038

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 4376kb

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.9358567276 -2.0000000000 -13.3523489999
-22.1464762180 -16.0762047055 -12.2418266590
-28.0274314334 -18.3185826362 -8.2433621863
-27.2661196513 -13.1593195843 -26.8825253977
-26.5349333669 -22.0666321326 -29.6160795685
-26.9678044775 -12.5576693960 -14.1867221345
-15.7785956689 -20.8626769117 -5....

result:

ok 3000 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 4384kb

input:

1000
33 73 79 36 44 48
96 66 45 9 13 14
81 64 9 50 30 26
59 64 65 39 44 13
47 63 7 20 11 27
36 20 52 13 22 20
20 30 29 12 2 12
46 36 41 34 28 39
97 54 70 16 14 5
79 8 97 41 24 18
95 83 59 47 15 50
85 78 67 22 13 17
96 32 70 32 15 18
27 34 76 38 13 29
47 86 95 42 17 34
41 50 50 25 33 22
82 42 81 18 4...

output:

-32.0158472904 -69.6840397768 -75.6380619841
-56.2413709597 -51.1942248145 -45.0000000000
-37.9051354998 -58.3508546862 -9.0000000000
-56.4875220827 -62.8262410453 -58.9556958380
-7.9608968122 -23.7309092007 -7.0000000000
-33.9487064051 -19.8750881749 -30.4828833892
-19.9103936531 -29.5316094778 -21...

result:

ok 3000 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 4200kb

input:

1000
171 722 964 22 53 44
379 126 423 98 56 54
233 473 879 86 44 48
159 864 365 39 44 63
847 363 207 70 11 77
736 920 652 13 72 70
318 278 347 44 87 66
691 693 1000 64 50 19
879 8 297 91 74 68
536 888 163 33 44 27
495 83 959 97 65 100
968 643 337 32 61 46
204 797 870 52 62 59
885 978 167 72 63 17
22...

output:

-171.0000000000 -213.8503925992 -223.0495547138
-177.4054054054 -126.0000000000 -222.5945945946
-233.0000000000 -255.0506796341 -243.8734756322
-159.0000000000 -219.7385787133 -199.6961293505
-201.8076390061 -276.3250359732 -207.0000000000
-723.0066274264 -657.1904853798 -652.0000000000
-314.4718729...

result:

ok 3000 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 4268kb

input:

1000
501 94 77 81 461 510
196 366 645 209 313 464
159 864 365 439 44 463
359 57 440 288 429 255
318 278 347 444 487 466
520 930 929 312 302 162
691 693 1000 564 250 519
33 292 661 856 572 306
410 665 850 503 313 592
947 186 395 292 817 634
466 581 266 563 125 647
672 653 583 469 216 496
554 457 945 ...

output:

-484.1585385881 -22.7058464901 -57.1533451396
-52.4261072631 -307.2218966712 -309.3347936072
-159.0000000000 -620.7560015228 -187.0286450312
-197.4710992887 -57.0000000000 -251.0389902452
-149.3682442103 -117.5609219043 -228.0354790874
-520.0000000000 -617.8645292883 -793.0155052242
-665.6553504727 ...

result:

ok 3000 numbers

Test #6:

score: 0
Accepted
time: 2ms
memory: 4380kb

input:

1000
79 26 423 98 56 54
33 473 79 86 44 48
59 64 365 39 44 63
95 83 959 97 65 100
4 97 870 52 62 59
405 53 8 11 66 75
96 3 407 45 46 67
57 847 5 38 42 72
77 173 16 68 47 53
54 57 945 80 52 83
795 18 100 67 56 72
67 42 748 48 3 50
29 35 566 52 38 18
23 56 116 35 37 15
800 12 62 54 99 74
7 696 95 38 3...

output:

-77.2457316580 -25.9959708702 -122.7398400581
-33.0000000000 -55.0506796341 -43.8734756322
-49.8375837930 -55.9206115494 -80.0045605181
-83.8886852656 -63.5948723469 -138.1207309074
-4.0000000000 -56.9882779177 -60.3094805222
-73.5487821068 -0.1487048402 -8.0000000000
-67.0241889772 -3.0000000000 -4...

result:

ok 3000 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 4348kb

input:

1000
171 722 64 22 53 44
379 26 423 98 56 54
233 473 79 86 44 48
381 864 9 100 80 76
159 64 365 39 44 63
847 63 207 70 11 77
189 410 33 78 87 17
736 920 52 13 72 70
318 278 47 44 87 66
91 693 1000 64 50 19
879 8 297 91 74 68
536 888 63 33 44 27
95 83 959 97 65 100
968 643 37 32 61 46
4 797 870 52 62...

output:

-115.1431813637 -81.0477271212 -64.0000000000
-77.4054054054 -26.0000000000 -122.5945945946
-121.6093444531 -164.2968711895 -79.0000000000
-80.2453046036 -102.1444761006 -9.0000000000
-124.4206432880 -64.0000000000 -98.6793041357
-139.8832943674 -63.0000000000 -132.8716033363
-119.7015334457 -110.66...

result:

ok 3000 numbers