Submission #1011165

# Submission time Handle Problem Language Result Execution time Memory
1011165 2024-06-30T03:13:26 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
260 ms 25352 KB
#include <bits/stdc++.h>
using i64 = long long;

struct Point {
    double x, y;
};

double dist(const Point &a, const Point &b) {
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return std::sqrt(dx * dx + dy * dy);
}

double insec(const Point &a, const Point &b) {
    double t1 = b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y;
    double t2 = b.x - a.x;
    return t1 / t2 / 2;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    double l;
    std::cin >> n >> l;

    std::deque<Point> pt;
    for (int i = 0; i < n; i++) {
        double x, y;
        std::cin >> x >> y;
        y = std::abs(y);

        while (pt.size() && pt.back().x == x) {
            if (pt.back().y >= y) {
                pt.pop_back();
            } else {
                break;
            }
        }
        if (pt.size() && pt.back().x == x) {
            continue;
        }
        pt.push_back({x, y});
    }

    double ans = 1E18;
    Point lt{0, 0}, rt{l, 0};
    for (int i = 0; i < (int)pt.size(); i++) {
        auto cur = pt[i];
        ans = std::min(ans, std::max(dist(cur, lt), dist(cur, rt)));
        if (i > 0) {
            auto pre = pt[i - 1];
            double x0 = insec(pre, cur);
            if (x0 > 0 && x0 < l) {
                Point mid{x0, 0};
                ans = std::min(ans, std::max(dist(pre, mid), dist(mid, cur)));
            }
        }
        if (i + 1 < (int)pt.size()) {
            auto nxt = pt[i + 1];
            double x0 = insec(cur, nxt);
            if (x0 > 0 && x0 < l) {
                Point mid{x0, 0};
                ans = std::min(ans, std::max(dist(cur, mid), dist(mid, nxt)));
            }
        }
    }
    std::cout << std::fixed << std::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 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 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 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 19 ms 2148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 2560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 12844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 8528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 15332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 10320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 183 ms 17924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 11960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 20364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 206 ms 13648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 246 ms 25352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 16952 KB Output isn't correct
2 Halted 0 ms 0 KB -