QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350510#6725. Pick UpwudibaolongAC ✓69ms3832kbC++141.4kb2024-03-10 19:40:472024-03-10 19:40:47

Judging History

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

  • [2024-03-10 19:40:47]
  • 评测
  • 测评结果:AC
  • 用时:69ms
  • 内存:3832kb
  • [2024-03-10 19:40:47]
  • 提交

answer

#include <bits/stdc++.h>
#define pdd pair<double, double>
#define x first
#define y second
#define int long long
#define pii pair<int, int>
#define esp 1e-7
using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;
    pii p[4];
    for (int i = 1; i <= 3; ++i) cin >> p[i].x >> p[i].y;
    int l = min(p[1].x, p[2].x), r = max(p[1].x, p[2].x), d = min(p[1].y, p[2].y), u = max(p[1].y, p[2].y);
    pii D = {max(l, min(r, p[3].x)), max(d, min(u, p[3].y))}; // AB构成矩形 内 离C哈密顿距离最近的点
    //cout << D.x << ' ' << D.y << '\n';
    int l1 = fabs(p[1].x - D.x) + fabs(p[1].y - D.y);
    int l2 = fabs(p[2].x - D.x) + fabs(p[2].y - D.y);
    double s = fabs(p[1].x - p[3].x) + fabs(p[1].y - p[3].y);
    double t1 = double(l1) / a, t2 = double(l2) / b;
    if (b * l1 == a * l2) printf("%.12f\n", t1 + (fabs(D.x - p[3].x) + fabs(D.y - p[3].y)) / b);
    else if (t1 < t2) {
        double xa, dx = (t2 - t1) * a;
        double dt = dx / (b - a);
        dx += a * dt;
        double ds = l1 + dx;
        if (ds > s) printf("%.12f\n", s / a);
        else printf("%.12f\n", t2 + dt + (s - ds) / b);
    }
    else {
        double dl = l1 - t2 * a;
        double dt = dl / (a + b);
        double ds = s - (t2 + dt) * a;
        printf("%.12f\n", t2 + dt + ds / b);
    }
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) solve();
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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.500000000000
1.000000000000
2.000000000000

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 69ms
memory: 3780kb

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.384607248572
1.178236811488
1.744616740037
0.470199832668
1.370533155904
2.305182945366
1.061124554447
1.061636780305
1.235959085540
2.333837989244
2.000606982282
0.977252836597
0.624150449526
1.185362533409
0.140506254667
0.180122576855
1.226313153310
5.927496595929
5.952019153241
0.495850184038
...

result:

ok 100000 numbers