QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#182750#6725. Pick Upucup-team004AC ✓66ms3924kbC++201.5kb2023-09-18 15:02:372023-09-18 15:02:37

Judging History

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

  • [2023-09-18 15:02:37]
  • 评测
  • 测评结果:AC
  • 用时:66ms
  • 内存:3924kb
  • [2023-09-18 15:02:37]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int a, b;
    std::cin >> a >> b;
    
    int xA, yA, xB, yB, xC, yC;
    std::cin >> xA >> yA >> xB >> yB >> xC >> yC;
    
    if (xB > xC) {
        xA *= -1;
        xB *= -1;
        xC *= -1;
    }
    if (yB > yC) {
        yA *= -1;
        yB *= -1;
        yC *= -1;
    }
    
    int dAB = std::abs(xA - xB) + std::abs(yA - yB);
    int dAC = std::abs(xA - xC) + std::abs(yA - yC);
    int dBC = std::abs(xB - xC) + std::abs(yB - yC);
    double ans = 1.0 * dAC / a;
    
    if (dAB + dAC == dBC) {
        ans = std::min(ans, 1.0 * dBC / b);
    } else if (dAB + dBC == dAC) {
        double d = 1.0 * dAB / (a + b) * b;
        ans = std::min(ans, (2 * d + dBC) / b);
    } else if (dAC + dBC == dAB) {
        double d = 1.0 * dAB / (a + b) * b;
        if (d >= dBC) {
            ans = std::min(ans, (2 * d - dBC) / b);
        }
    } else {
        double dAD = (1.0 * dAB + dAC - dBC) / 2;
        double dBD = dAB - dAD;
        if (dAD / a < dBD / b) {
            ans = std::min(ans, 1.0 * dBC / b);
        } else {
            double d = 1.0 * dAB / (a + b) * b;
            ans = std::min(ans, (1.0 * dBC + 2 * (d - dBD)) / b);
        }
    }
    
    std::cout << ans << "\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;
}

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

详细

Test #1:

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

input:

3
1 2
0 2 1 0 2 2
1 3
1 1 0 1 3 1
1 2
0 0 100 100 1 1

output:

1.5000000000
1.0000000000
2.0000000000

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 66ms
memory: 3924kb

input:

100000
158260522 877914575
602436426 24979445 861648772 623690081 433933447 476190629
731963982 822804784
450968417 430302156 982631932 161735902 880895728 923078537
317063340 492686568
773361868 125660016 650287940 839296263 462224593 492601449
576823355 782177068
404011431 818008580 954291757 1604...

output:

1.3846072486
1.1782368115
1.7446167400
0.4701998327
1.3705331559
2.3051829454
1.0611245544
1.0616367803
1.2359590855
2.3338379892
2.0006069823
0.9772528366
0.6241504495
1.1853625334
0.1405062547
0.1801225769
1.2263131533
5.9274965959
5.9520191532
0.4958501840
1.3378103336
1.4286377021
1.1692600922
6...

result:

ok 100000 numbers