# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
898989 |
2024-01-05T10:33:16 Z |
WLZ |
Mobile (BOI12_mobile) |
C++17 |
|
377 ms |
104644 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(10) << ans << '\n';
return 0;
}
# |
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 |
0 ms |
348 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 |
604 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 |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
3816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
3420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
11344 KB |
Output is correct |
2 |
Incorrect |
28 ms |
4180 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
5036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
9028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
52028 KB |
Output is correct |
2 |
Correct |
174 ms |
23780 KB |
Output is correct |
3 |
Correct |
208 ms |
23264 KB |
Output is correct |
4 |
Incorrect |
217 ms |
25584 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
24176 KB |
Output is correct |
2 |
Incorrect |
181 ms |
26196 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
227 ms |
75008 KB |
Output is correct |
2 |
Incorrect |
236 ms |
28500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
29104 KB |
Output is correct |
2 |
Incorrect |
229 ms |
30612 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
80916 KB |
Output is correct |
2 |
Incorrect |
233 ms |
33108 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
33876 KB |
Output is correct |
2 |
Incorrect |
265 ms |
35400 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
288 ms |
86768 KB |
Output is correct |
2 |
Incorrect |
281 ms |
37900 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
296 ms |
38676 KB |
Output is correct |
2 |
Incorrect |
289 ms |
40008 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
348 ms |
104644 KB |
Output is correct |
2 |
Incorrect |
330 ms |
47248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
377 ms |
48136 KB |
Output is correct |
2 |
Incorrect |
355 ms |
51580 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |