QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#321850#7127. 3 pointskilo_tobo_tarjenAC ✓1ms3892kbC++202.0kb2024-02-05 18:28:052024-02-05 18:28:06

Judging History

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

  • [2024-02-05 18:28:06]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3892kb
  • [2024-02-05 18:28:05]
  • 提交

answer

#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> s;
using i64 = long long;
// using u32 = unsigned int;
// using u64 = unsigned long long;
// using i128 = __int128_t;
using namespace std;
const int N = 5e5 + 5;
// const int B = 455;
// const int M = 2e6 + 5;
// const int base = 13131;
// const int base = 17171;
// const int mod = 998244353;
const int mod = 1e9 + 7;
// const i64 mod = 1000000000000000003LL;
// const double pi = acos(-1);

int n = 3, a[3], b[3];
void solve()
{
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    double l = -1e5, r = 1e5, mid1, mid2;
    int cnt = 100;
    auto cal = [&](double x) -> double
    {
        double l = -1e5, r = 1e5, mid1, mid2;
        int cnt = 100;
        auto cal1 = [&](double x, double y) -> double
        {
            double res = 0;
            res += sqrt((a[0] - x) * (a[0] - x) + (b[0] - y) * (b[0] - y));
            res += 2 * sqrt((a[1] - x) * (a[1] - x) + (b[1] - y) * (b[1] - y));
            res += 3 * sqrt((a[2] - x) * (a[2] - x) + (b[2] - y) * (b[2] - y));
            return res;
        };
        while (cnt--)
        {
            mid1 = l + (r - l) / 3;
            mid2 = mid1 + (r - l) / 3;
            if (cal1(x, mid1) < cal1(x, mid2))
                r = mid2;
            else
                l = mid1;
        }
        return min(cal1(x, mid1), cal1(x, mid2));
    };
    while (cnt--)
    {
        mid1 = l + (r - l) / 3;
        mid2 = mid1 + (r - l) / 3;
        if (cal(mid1) < cal(mid2))
            r = mid2;
        else
            l = mid1;
    }
    cout << min(cal(mid1), cal(mid2)) << '\n';
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    cout << fixed << setprecision(10);
    while (t--)
        solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3752kb

input:

0 0
0 0
1 0

output:

3.0000000000

result:

ok found '3.0000000', expected '3.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

3802 -1400
-1785 6079
-1696 4064

output:

11785.2709213286

result:

ok found '11785.2709213', expected '11785.2709213', error '0.0000000'

Test #3:

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

input:

-328 -657
-328 -657
-8676 1661

output:

25991.5380845382

result:

ok found '25991.5380845', expected '25991.5380845', error '0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

1769 3696
-5156 3323
3100 -5945

output:

34556.4118182394

result:

ok found '34556.4118182', expected '34556.4118182', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

-3471 -9470
2703 -7464
-7061 -5800

output:

24943.4593375669

result:

ok found '24943.4593376', expected '24943.4593376', error '0.0000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3848kb

input:

-7519 -3395
8301 1749
9545 -7037

output:

35195.5937017658

result:

ok found '35195.5937018', expected '35195.5937018', error '0.0000000'

Test #7:

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

input:

-3840 -9039
-5120 -3251
-5120 -3251

output:

5927.8448022869

result:

ok found '5927.8448023', expected '5927.8448023', error '0.0000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

-3303 200
-2722 6597
6508 -1021

output:

33822.1680442459

result:

ok found '33822.1680442', expected '33822.1680442', error '0.0000000'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

5126 943
5126 943
5031 6532

output:

16769.4219936168

result:

ok found '16769.4219936', expected '16769.4219936', error '0.0000000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

2242 6320
995 -5756
-5013 -154

output:

26152.6199373159

result:

ok found '26152.6199373', expected '26152.6199373', error '0.0000000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

-4705 7940
-9475 8840
-9475 8840

output:

4854.1631616582

result:

ok found '4854.1631617', expected '4854.1631617', error '0.0000000'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

5561 4985
3155 -2847
2181 -3071

output:

10735.1859130249

result:

ok found '10735.1859130', expected '10735.1859130', error '0.0000000'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

1430 7989
-6131 6366
-8506 4408

output:

16717.7115137675

result:

ok found '16717.7115138', expected '16717.7115138', error '0.0000000'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

9632 2710
-7975 -4422
-7975 -4422

output:

18996.6279376104

result:

ok found '18996.6279376', expected '18996.6279376', error '0.0000000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

-1713 9474
7326 4791
-26 5276

output:

19260.2469775957

result:

ok found '19260.2469776', expected '19260.2469776', error '0.0000000'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

-5843 -9784
5482 3707
-6917 -9440

output:

37270.7297001647

result:

ok found '37270.7297002', expected '37270.7297002', error '0.0000000'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

5899 -7081
8453 6144
-1243 9615

output:

38756.5333739589

result:

ok found '38756.5333740', expected '38756.5333740', error '0.0000000'

Test #18:

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

input:

-1545 -8299
-5880 1726
-5880 1726

output:

10922.1266244262

result:

ok found '10922.1266244', expected '10922.1266244', error '0.0000000'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

-5675 -114
-6342 731
3553 -394

output:

29149.7417861595

result:

ok found '29149.7417862', expected '29149.7417862', error '0.0000000'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

-2454 216
-2489 -9740
-7544 -6814

output:

20360.7521206795

result:

ok found '20360.7521207', expected '20360.7521207', error '0.0000000'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

7262 5984
-5386 1535
-9950 5835

output:

29753.7925507608

result:

ok found '29753.7925508', expected '29753.7925508', error '0.0000000'