# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
898990 |
2024-01-05T10:34:11 Z |
WLZ |
Mobile (BOI12_mobile) |
C++17 |
|
346 ms |
95728 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
using ld = long double;
constexpr ld inf = numeric_limits<long double>::infinity();
constexpr ld eps = 1e-9;
// https://github.com/kth-competitive-programming/kactl/blob/main/content/geometry/Point.h
template<class T>
struct Point {
typedef Point P;
T x, y;
explicit Point(T _x = 0, T _y = 0) : x(_x), y(_y) {}
P operator+(P p) const { return P(x + p.x, y + p.y); }
P operator-(P p) const { return P(x - p.x, y - p.y); }
P operator/(T d) const { return P(x / d, y / d); }
T dist2() const { return x*x + y*y; }
ld dist() const { return sqrt((ld) dist2()); }
P perp() const { return P(-y, x); }
};
// #include "lib/geodeb.h"
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
// GD_INIT("geodeb.html");
int n; ld l; cin >> n >> l;
vector< Point<ld> > p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].x >> p[i].y;
p[i].y = abs(p[i].y);
// GD_POINT(p[i].x, p[i].y, "black bold");
}
vector<ld> ends = {-inf};
vector< Point<ld> > st = {p[0]};
for (int i = 1; i < n; i++) {
// GD_LAYER();
// GD_POINT(p[i].x, p[i].y, "red bold");
if (abs(p[i].x - p[i - 1].x) < eps) continue;
while (true) {
// GD_LAYER();
auto q = st.back();
// GD_SEGMENT(p[i].x, p[i].y, q.x, q.y, "red bold");
auto m = (p[i] + q) / 2;
// auto tmp = (q - p[i]).perp() + m;
// GD_LINE(m.x, m.y, tmp.x, tmp.y, "black");
ld k = -m.y / (q.x - p[i].x);
ld x = m.x - k * (q.y - p[i].y);
// GD_POINT(x, 0, "red bold");
if (x < ends.back()) {
st.pop_back(); ends.pop_back();
} else {
st.push_back(p[i]); ends.push_back(x);
break;
}
}
}
ends.push_back(inf);
ld ans = 0.0;
for (int i = 0; i < (int) st.size(); i++) {
ans = max(ans, (Point<ld>(clamp(ends[i], 0.0l, l), 0) - st[i]).dist());
ans = max(ans, (Point<ld>(clamp(ends[i + 1], 0.0l, l), 0) - st[i]).dist());
}
cout << fixed << setprecision(6) << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
3156 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
10008 KB |
Output is correct |
2 |
Incorrect |
34 ms |
2904 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
3416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
7492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
47580 KB |
Output is correct |
2 |
Correct |
171 ms |
16112 KB |
Output is correct |
3 |
Correct |
166 ms |
16216 KB |
Output is correct |
4 |
Incorrect |
213 ms |
16212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
15964 KB |
Output is correct |
2 |
Incorrect |
193 ms |
19640 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
222 ms |
70200 KB |
Output is correct |
2 |
Incorrect |
196 ms |
19240 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
19244 KB |
Output is correct |
2 |
Incorrect |
209 ms |
22960 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
75100 KB |
Output is correct |
2 |
Incorrect |
232 ms |
22372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
234 ms |
22376 KB |
Output is correct |
2 |
Incorrect |
240 ms |
26184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
81028 KB |
Output is correct |
2 |
Incorrect |
291 ms |
25432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
25508 KB |
Output is correct |
2 |
Incorrect |
277 ms |
29332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
95728 KB |
Output is correct |
2 |
Incorrect |
343 ms |
31760 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
31764 KB |
Output is correct |
2 |
Incorrect |
343 ms |
38160 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |