QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137727 | #6725. Pick Up | mshcherba# | AC ✓ | 196ms | 3796kb | C++17 | 1.9kb | 2023-08-10 17:07:15 | 2023-08-10 17:07:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;
const db EPS = 1e-9;
db a[2][3];
pair<db, db> solve() {
db delta = a[0][0] * a[1][1] - a[1][0] * a[0][1];
db deltaX = a[0][2] * a[1][1] - a[1][2] * a[0][1];
db deltaY = a[0][0] * a[1][2] - a[1][0] * a[0][2];
return {deltaX / delta, deltaY / delta};
}
db va, vb, xA, yA, xB, yB, xC, yC;
db f(db xD, db yD) {
db t = (abs(xD - xA) + abs(yD - yA)) / va;
if (abs((abs(xD - xB) + abs(yD - yB)) / vb - t) > EPS) {
return 1e18;
}
return t + (abs(xC - xD) + abs(yC - yD)) / vb;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
int t;
cin >> t;
while (t--) {
cin >> va >> vb >> xA >> yA >> xB >> yB >> xC >> yC;
if (xA > xC) {
xA *= -1;
xB *= -1;
xC *= -1;
}
if (yA > yC) {
yA *= -1;
yB *= -1;
yC *= -1;
}
db ans = (xC - xA + yC - yA) / va;
for (int sx : {-1, 1}) {
for (int sy : {-1, 1}) {
a[0][0] = 1 / va + sx / vb;
a[0][1] = 1 / va + sy / vb;
a[0][2] = (xA + yA) / va + (sx * xB + sy * yB) / vb;
for (db xD : {xA, xB, xC}) {
a[1][0] = 1;
a[1][1] = 0;
a[1][2] = xD;
auto [x, y] = solve();
assert(abs(x - xD) < EPS);
ans = min(ans, f(x, y));
}
for (db yD : {yA, yB, yC}) {
a[1][0] = 0;
a[1][1] = 1;
a[1][2] = yD;
auto [x, y] = solve();
assert(abs(y - yD) < EPS);
ans = min(ans, f(x, y));
}
}
}
cout << ans << "\n";
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
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: 196ms
memory: 3796kb
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