QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#350496 | #6725. Pick Up | wudibaolong | WA | 126ms | 3924kb | C++14 | 1.4kb | 2024-03-10 19:32:14 | 2024-03-10 19:32:14 |
Judging History
answer
#include <bits/stdc++.h>
#define pdd pair<double, double>
#define x first
#define y second
#define int long long
#define esp 1e-7
using namespace std;
void solve() {
double a, b;
cin >> a >> b;
pdd p[4];
for (int i = 1; i <= 3; ++i) cin >> p[i].x >> p[i].y;
double 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);
pdd D = {max(l, min(r, p[3].x)), max(d, min(u, p[3].y))}; // AB构成矩形 内 离C哈密顿距离最近的点
//cout << D.x << ' ' << D.y << '\n';
double l1 = fabs(p[1].x - D.x) + fabs(p[1].y - D.y);
double 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 = l1 / a, t2 = l2 / b;
if (fabs(t1 - t2) <= esp) cout << t1 + (fabs(D.x - p[3].x) + fabs(D.y - p[3].y)) / b << '\n';
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) cout << s / a << '\n';
else cout << t2 + dt + (s - ds) / b << '\n';
}
else {
double dl = l1 - t2 * a;
double dt = dl / (a + b);
double ds = s - (t2 + dt) * a;
cout << t2 + dt + ds / b << '\n';
}
}
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3924kb
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.5 1 2
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 126ms
memory: 3820kb
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.38461 1.17824 1.74462 0.4702 1.37053 2.30518 1.06112 1.06164 1.23596 2.33384 2.00061 0.977253 0.62415 1.18536 0.140506 0.180123 1.22631 5.9275 5.95202 0.49585 1.33781 1.42864 1.16926 68.9411 2.42419 1.91716 3.66809 0.154011 2.82396 1.12242 1.13797 0.964164 1.47217 0.592077 0.585821 4.60195 0.65897...
result:
wrong answer 1st numbers differ - expected: '1.3846072', found: '1.3846100', error = '0.0000020'