답안 #1098015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1098015 2024-10-08T19:47:23 Z 0x34c Mobile (BOI12_mobile) C++17
95 / 100
562 ms 131072 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll
#define ld long double
#define pdd pair<ld, ld>

using namespace std;

int dist2(pii a, pii b)
{
    return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}

ld dist(pii a, ld x)
{
    return sqrt((((ld)a.first) - x) * (((ld)a.first) - x) + (ld)(a.second * a.second));
}

const int INF2 = 1e12;
const int INF = 1e9 + 1;
ld eps = 1e-4;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, L;
    cin >> N >> L;

    vector<pii> inp(N);
    map<int, int> closest;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;

        inp[i] = {x, y};

        if (!closest.count(x))
            closest[x] = y;
        else
            closest[x] = (abs(closest[x]) > abs(y) ? y : closest[x]);
    }

    vector<pii> pts;
    for (pii p : closest)
        pts.push_back(p);

    N = pts.size();

    auto calc_bp = [&](int idx1, int idx2)
    {
        ld x1 = pts[idx1].first, y1 = pts[idx1].second;
        ld x2 = pts[idx2].first, y2 = pts[idx2].second;

        return ((ld)0.5) * (x1 + x2 + (y1 * y1 - y2 * y2) / (x1 - x2));
    };

    stack<int> stk;
    stk.push(0);
    vector<ld> dists, bps;
    for (int i = 1; i < N; i++)
    {
        while (stk.empty())
        {
        }
        ld bp = calc_bp(stk.top(), i);
        bool emp = false;

        while (!bps.empty() && bps.back() > bp)
        {
            bps.pop_back();
            stk.pop();
            dists.pop_back();
            if (stk.empty())
                emp = true;
            else
                bp = calc_bp(stk.top(), i);
        }

        if (!emp)
        {
            bps.push_back(bp);
            dists.push_back(dist(pts[i], bp));
        }
        stk.push(i);
    }

    ld mx_dist = 0;
    for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
    {
        if (bps[i] < 0 || bps[i] > L)
            continue;
        mx_dist = max(mx_dist, dists[i]);
    }

    ld mn_start = INF2, mn_end = INF2;
    for (int i = 0; i < N; i++)
    {
        mn_start = min(mn_start, dist(pts[i], 0));
        mn_end = min(mn_end, dist(pts[i], L));
    }

    mx_dist = max({mx_dist, mn_start, mn_end});
    cout << setprecision(4) << fixed << mx_dist << endl;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:93:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'long unsigned int' [-Wsign-compare]
   93 |     for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Correct 1 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 900 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 1020 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 3 ms 1112 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 8676 KB Output is correct
2 Correct 31 ms 7368 KB Output is correct
3 Correct 23 ms 6356 KB Output is correct
4 Correct 42 ms 9492 KB Output is correct
5 Correct 7 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2908 KB Output is correct
2 Correct 31 ms 5584 KB Output is correct
3 Correct 38 ms 9168 KB Output is correct
4 Correct 41 ms 9952 KB Output is correct
5 Correct 43 ms 10700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 15044 KB Output is correct
2 Correct 35 ms 7112 KB Output is correct
3 Correct 39 ms 13536 KB Output is correct
4 Correct 50 ms 12236 KB Output is correct
5 Correct 31 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 7372 KB Output is correct
2 Correct 44 ms 7156 KB Output is correct
3 Correct 34 ms 4692 KB Output is correct
4 Correct 46 ms 12488 KB Output is correct
5 Correct 44 ms 10436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 14016 KB Output is correct
2 Correct 40 ms 7088 KB Output is correct
3 Correct 33 ms 4948 KB Output is correct
4 Correct 46 ms 12228 KB Output is correct
5 Correct 43 ms 10448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 74672 KB Output is correct
2 Correct 151 ms 16720 KB Output is correct
3 Correct 154 ms 16220 KB Output is correct
4 Correct 280 ms 57276 KB Output is correct
5 Correct 249 ms 43712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 16976 KB Output is correct
2 Correct 249 ms 56236 KB Output is correct
3 Correct 218 ms 27196 KB Output is correct
4 Correct 279 ms 57024 KB Output is correct
5 Correct 260 ms 52420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 310 ms 103856 KB Output is correct
2 Correct 179 ms 19712 KB Output is correct
3 Correct 170 ms 19164 KB Output is correct
4 Correct 321 ms 75712 KB Output is correct
5 Correct 290 ms 45240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 177 ms 19848 KB Output is correct
2 Correct 299 ms 71408 KB Output is correct
3 Correct 248 ms 26820 KB Output is correct
4 Correct 354 ms 75460 KB Output is correct
5 Correct 316 ms 68056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 370 ms 117532 KB Output is correct
2 Correct 202 ms 22700 KB Output is correct
3 Correct 202 ms 22096 KB Output is correct
4 Correct 403 ms 85184 KB Output is correct
5 Correct 350 ms 45256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 23092 KB Output is correct
2 Correct 349 ms 80320 KB Output is correct
3 Correct 317 ms 36556 KB Output is correct
4 Correct 373 ms 84928 KB Output is correct
5 Correct 361 ms 75456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 394 ms 130936 KB Output is correct
2 Correct 221 ms 25680 KB Output is correct
3 Correct 209 ms 25016 KB Output is correct
4 Correct 471 ms 95164 KB Output is correct
5 Correct 428 ms 63684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 26196 KB Output is correct
2 Correct 420 ms 89272 KB Output is correct
3 Correct 381 ms 38588 KB Output is correct
4 Correct 444 ms 94912 KB Output is correct
5 Correct 433 ms 83200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 429 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 259 ms 32468 KB Output is correct
2 Correct 501 ms 110940 KB Output is correct
3 Correct 464 ms 51648 KB Output is correct
4 Correct 562 ms 114368 KB Output is correct
5 Correct 537 ms 99768 KB Output is correct