# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
799325 |
2023-07-31T12:40:23 Z |
tch1cherin |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
84232 KB |
#include <bits/stdc++.h>
using namespace std;
using D = long double;
struct Point {
D x, y;
Point operator+(Point b) { return {x + b.x, y + b.y}; }
Point operator-(Point b) { return {x - b.x, y - b.y}; }
Point operator*(D k) { return {x * k, y * k}; }
};
D dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
D cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
D norm(Point a) { return dot(a, a); }
D length(Point a) { return sqrtl(norm(a)); }
Point normalize(Point a, D k) { return a * (k / length(a)); }
D pointToLine(Point C, Point A, Point B) {
return abs(cross(C - A, C - B) / length(B - A));
}
Point getHeight(Point C, Point A, Point B) {
Point v = B - A;
return A + normalize(v, dot(v, C - A) / length(v));
}
D dequal(D a, D b) { return abs(a - b) < 1e-12l; }
D dless(D a, D b) { return a < b && !dequal(a, b); }
D sqr(D a) { return a * a; }
bool isZero(Point a) { return dequal(a.x, 0) && dequal(a.y, 0); }
vector<Point> getIntersection(Point O, D r, Point A, Point B) {
D h = pointToLine(O, A, B);
if (dless(r, h)) {
return {};
}
Point H = getHeight(O, A, B);
Point v = B - A;
v = normalize(v, sqrtl(sqr(r) - sqr(h)));
if (isZero(v)) {
return {H};
} else {
return {H - v, H + v};
}
}
int main() {
cout << fixed << setprecision(9);
cin.tie(nullptr)->sync_with_stdio(false);
int N, L;
cin >> N >> L;
vector<Point> points(N);
for (auto &[x, y] : points) {
cin >> x >> y;
}
D l = 0, r = 1e9;
for (int i = 0; i < 100; i++) {
D R = (l + r) / 2;
vector<pair<D, D>> seg;
for (auto p : points) {
vector<Point> I = getIntersection(p, R, {0, 0}, {(D)L, 0});
if (I.size() == 1) {
seg.push_back({I[0].x, I[0].x});
} else if (I.size() == 2) {
if (I[0].x > I[1].x) {
swap(I[0], I[1]);
}
seg.push_back({I[0].x, I[1].x});
}
}
sort(seg.begin(), seg.end());
long double max_r = 0;
bool good = true;
for (auto [ll, rr] : seg) {
if (dless(L, ll)) {
break;
}
if (dless(max_r, ll)) {
good = false;
} else {
max_r = max(max_r, rr);
}
}
if (good) {
r = R;
} else {
l = R;
}
}
cout << r << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
320 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
660 KB |
Output is correct |
2 |
Incorrect |
22 ms |
656 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
952 KB |
Output is correct |
2 |
Correct |
85 ms |
976 KB |
Output is correct |
3 |
Correct |
90 ms |
944 KB |
Output is correct |
4 |
Correct |
37 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
952 KB |
Output is correct |
2 |
Correct |
84 ms |
984 KB |
Output is correct |
3 |
Correct |
94 ms |
964 KB |
Output is correct |
4 |
Correct |
36 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
596 ms |
9944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
664 ms |
10084 KB |
Output is correct |
2 |
Correct |
561 ms |
9668 KB |
Output is correct |
3 |
Correct |
623 ms |
10648 KB |
Output is correct |
4 |
Correct |
559 ms |
10608 KB |
Output is correct |
5 |
Correct |
584 ms |
11336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
756 ms |
10632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
12360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1036 ms |
12224 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
52336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
51328 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
72720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1099 ms |
71468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1051 ms |
75860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
74168 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
78948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1033 ms |
77216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
84232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
81364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |