QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137911 | #6725. Pick Up | PetroTarnavskyi# | TL | 16ms | 3720kb | C++17 | 1.5kb | 2023-08-10 18:58:05 | 2023-08-10 18:58:07 |
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;
db dist(db x0, db y0, db x1, db y1, db v){
return (abs(x0 - x1) + abs(y0 - y1)) / v;
}
int xA, yA, xB, yB, xC, yC;
int a, b;
db d(db x, db y){
return max(dist(xA, yA, x, y, a), dist(xB, yB, x, y, b)) + dist(x, y, xC, yC, b);
}
db findY(db x){
db Ly = -1e9, Ry = 1e9;
FOR(it, 0, 300){
db m1y = (2 * Ly + Ry) / 3.0;
db m2y = (Ly + 2 * Ry) / 3.0;
if(d(x, m1y) > d(x, m2y))
Ly = m1y;
else
Ry = m2y;
}
return d(x, Ry);
}
void solve(){
cin >> a >> b;
cin >> xA >> yA >> xB >> yB >> xC >> yC;
db ans = dist(xA, yA, xC, yC, a);
db Lx = -1e9, Rx = 1e9;
FOR(it, 0, 300){
db m1x = (2 * Lx + Rx) / 3.0;
db m2x = (Lx + 2 * Rx) / 3.0;
if(findY(m1x) > findY(m2x))
Lx = m1x;
else
Rx = m2x;
}
ans = min(ans, findY(Rx));
cout << fixed << setprecision(10) << ans << "\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--)
solve();
//cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 3720kb
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: -100
Time Limit Exceeded
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...