Submission #898989

#TimeUsernameProblemLanguageResultExecution timeMemory
898989WLZMobile (BOI12_mobile)C++17
0 / 100
377 ms104644 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...