Submission #899006

# Submission time Handle Problem Language Result Execution time Memory
899006 2024-01-05T10:48:05 Z WLZ Mobile (BOI12_mobile) C++17
0 / 100
162 ms 113068 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 = max(py, y);
        else {
            if (px > (int) -2e9) p.emplace_back(px, py);
            px = x; py = 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 1 ms 344 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 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 6352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 11248 KB Output is correct
2 Incorrect 14 ms 4312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 4820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 9672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 92 ms 56308 KB Output is correct
2 Incorrect 74 ms 12676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 13192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 132 ms 82528 KB Output is correct
2 Incorrect 103 ms 14732 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 15372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 140 ms 89344 KB Output is correct
2 Incorrect 107 ms 17056 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 17828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 132 ms 96488 KB Output is correct
2 Incorrect 108 ms 19284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 20272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 113068 KB Output is correct
2 Incorrect 133 ms 24012 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 146 ms 25164 KB Output isn't correct
2 Halted 0 ms 0 KB -