# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
899011 |
2024-01-05T10:49:26 Z |
WLZ |
Mobile (BOI12_mobile) |
C++17 |
|
170 ms |
103592 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "debug.hpp"
#include "lib/geodeb.h"
#else
#define debug(...)
#define GD_INIT(...)
#define GD_POINT(...)
#define GD_LAYER(...)
#define GD_LINE(...)
#define GD_SEGMENT(...)
#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); }
};
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
GD_INIT("geodeb.html");
int n; ld l; cin >> n >> l;
vector< Point<int> > p1(n);
for (int i = 0; i < n; i++) cin >> p1[i].x >> p1[i].y;
int px = (int) -2e9, py = -2e9;
vector< Point<ld> > p;
for (auto &[x, y] : p1) {
if (x == px) py = min(py, abs(y));
else {
if (px > (int) -2e9) p.emplace_back(px, py);
px = x; py = abs(y);
}
}
p.emplace_back(px, py);
n = (int) p.size();
for (auto &[x, y] : p) GD_POINT(x, 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");
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(4) << ans << '\n';
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:52:16: warning: unused structured binding declaration [-Wunused-variable]
52 | for (auto &[x, y] : p) GD_POINT(x, y, "black bold");
| ^~~~~~
mobile.cpp:66:18: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
66 | auto tmp = (q - p[i]).perp() + m;
| ^~~
# |
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 |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
5844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
12752 KB |
Output is correct |
2 |
Incorrect |
13 ms |
3292 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
8140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
52004 KB |
Output is correct |
2 |
Correct |
90 ms |
4824 KB |
Output is correct |
3 |
Correct |
78 ms |
11988 KB |
Output is correct |
4 |
Incorrect |
124 ms |
30912 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
5032 KB |
Output is correct |
2 |
Incorrect |
107 ms |
30268 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
77588 KB |
Output is correct |
2 |
Incorrect |
79 ms |
5420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
5420 KB |
Output is correct |
2 |
Incorrect |
111 ms |
47096 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
84136 KB |
Output is correct |
2 |
Incorrect |
91 ms |
6220 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
6228 KB |
Output is correct |
2 |
Incorrect |
128 ms |
49824 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
93104 KB |
Output is correct |
2 |
Incorrect |
106 ms |
6992 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
6992 KB |
Output is correct |
2 |
Incorrect |
146 ms |
50592 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
103592 KB |
Output is correct |
2 |
Incorrect |
129 ms |
8532 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
8752 KB |
Output is correct |
2 |
Incorrect |
170 ms |
59812 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |