답안 #1031459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031459 2024-07-22T21:06:59 Z Boas Mobile (BOI12_mobile) C++17
100 / 100
1000 ms 74884 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T1, typename T2>
using indexed_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_set = indexed_map<T, null_type>;

#define loop(x, i) for (int i = 0; i < (x); i++)
#define loop1(x, i) for (int i = 1; i <= (x); i++)
#define rev(x, i) for (int i = (int)(x) - 1; i >= 0; i--)
#define itloop(x) for (auto it = begin(x); x != end(x); it++)
#define itrev(x) for (auto it = rbegin(x); x != rend(x); it++)
// #define int long long
#define INF ((int64_t)(4e18 + 1))
#define INF32 ((int32_t)(2e9 + 1))
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define existsIn(x, l) (count(ALL(l), x) > 0)
#define removeIn(x, l) l.erase(find(ALL(l), x))
#define pb push_back
#define sz(x) (int)(x).size()
#define x first
#define y second
#define var const auto &
#define foreach(l) for (var e : l)

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<viii> vviii;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;
typedef vector<si> vsi;
typedef vector<sii> vsii;
typedef vector<vsi> vvsi;
typedef vector<string> vstr;
typedef vector<vector<string>> vvstr;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vi::iterator viit;
typedef si::iterator siit;
typedef int8_t in8;
typedef int16_t in16;
typedef int32_t in32;
typedef int64_t in64;

typedef double ld;
typedef vector<pair<ld, ld>> vff;
// ld eps = 4e-4; // 13pt
ld eps = 5e-4; // 13pt
// ld eps = 1e-18; // 4pt: TLE

void solve()
{
    int N;
    ld L;
    cin >> N >> L;
    vii points;
    loop(N, i)
    {
        int x, y;
        cin >> x >> y;
        if (!points.empty() && points.back().x == x)
        {
            points.back().y = min(abs(y), abs(points.back().y));
        }
        else
            points.pb({x, y});
    }
    N = points.size();
    vff a;
    for (var[x, y] : points)
        a.pb({x, y});
    /*vff a(N);
    loop(N, i)
    {
        cin >> a[i].x >> a[i].y;
    }*/
    ld lo = 0.0L, hi = sqrt(1e18L + L * L);
    while (hi - lo > eps)
    {
        ld R = lo + (hi - lo) / 2.0L;
        vff segments;
        loop(N, i)
        {
            auto [x, y] = a[i];
            ld D = (R * R) - ((ld)y * (ld)y);
            if (D >= 0.0L)
            {
                ld l = x - sqrt(D);
                ld r = x + sqrt(D);
                l = max(l, 0.0);
                r = min(r, L);
                if (l > r)
                    continue;
                while (!segments.empty() && segments.back().x > l)
                {
                    segments.pop_back();
                }
                segments.pb({l, r});
            }
        }
        if (segments.empty())
        {
            lo = R;
            continue;
        }
        // sort(ALL(segments));
        bool highwayCovered = 1;
        ld l = segments[0].first, r = segments[0].second;
        if (l > 0)
            highwayCovered = 0;
        else
        {
            for (auto [l_i, r_i] : segments)
            {
                if (l_i > r)
                {
                    highwayCovered = 0;
                    break;
                }
                r = max(r, r_i);
            }
        }
        if (r < L)
            highwayCovered = 0;
        if (highwayCovered)
        {
            hi = R;
        }
        else
            lo = R;
    }
    ld res = lo + (hi - lo) / 2.0L;
    cout << fixed << setprecision(4) << res << endl;
}

signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 2 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 4 ms 796 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 3 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 4 ms 804 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 780 KB Output is correct
2 Correct 4 ms 796 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 780 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 5280 KB Output is correct
2 Correct 43 ms 3696 KB Output is correct
3 Correct 36 ms 3628 KB Output is correct
4 Correct 32 ms 5452 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 768 KB Output is correct
2 Correct 24 ms 2864 KB Output is correct
3 Correct 37 ms 5264 KB Output is correct
4 Correct 39 ms 5612 KB Output is correct
5 Correct 27 ms 5944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 6112 KB Output is correct
2 Correct 46 ms 3540 KB Output is correct
3 Correct 52 ms 5244 KB Output is correct
4 Correct 28 ms 6084 KB Output is correct
5 Correct 17 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3136 KB Output is correct
2 Correct 37 ms 3168 KB Output is correct
3 Correct 16 ms 1256 KB Output is correct
4 Correct 35 ms 6072 KB Output is correct
5 Correct 43 ms 5696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 6424 KB Output is correct
2 Correct 37 ms 3200 KB Output is correct
3 Correct 16 ms 1256 KB Output is correct
4 Correct 29 ms 6132 KB Output is correct
5 Correct 43 ms 5816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 497 ms 28620 KB Output is correct
2 Correct 63 ms 8668 KB Output is correct
3 Correct 60 ms 8260 KB Output is correct
4 Correct 145 ms 37960 KB Output is correct
5 Correct 178 ms 29844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 972 KB Output is correct
2 Correct 298 ms 28036 KB Output is correct
3 Correct 112 ms 6296 KB Output is correct
4 Correct 142 ms 28220 KB Output is correct
5 Correct 192 ms 26448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 668 ms 41448 KB Output is correct
2 Correct 93 ms 10116 KB Output is correct
3 Correct 69 ms 9540 KB Output is correct
4 Correct 165 ms 51000 KB Output is correct
5 Correct 184 ms 30136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 860 KB Output is correct
2 Correct 358 ms 41196 KB Output is correct
3 Correct 105 ms 5156 KB Output is correct
4 Correct 188 ms 39280 KB Output is correct
5 Correct 225 ms 39580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 769 ms 44324 KB Output is correct
2 Correct 81 ms 11624 KB Output is correct
3 Correct 98 ms 10948 KB Output is correct
4 Correct 197 ms 57012 KB Output is correct
5 Correct 179 ms 29256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 808 KB Output is correct
2 Correct 410 ms 53180 KB Output is correct
3 Correct 136 ms 15864 KB Output is correct
4 Correct 243 ms 57792 KB Output is correct
5 Correct 276 ms 51620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 854 ms 48304 KB Output is correct
2 Correct 95 ms 13240 KB Output is correct
3 Correct 88 ms 12400 KB Output is correct
4 Correct 249 ms 61908 KB Output is correct
5 Correct 271 ms 39464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 788 KB Output is correct
2 Correct 462 ms 58284 KB Output is correct
3 Correct 155 ms 16860 KB Output is correct
4 Correct 226 ms 63192 KB Output is correct
5 Correct 315 ms 54832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1000 ms 56236 KB Output is correct
2 Correct 119 ms 16256 KB Output is correct
3 Correct 108 ms 15280 KB Output is correct
4 Correct 284 ms 74884 KB Output is correct
5 Correct 291 ms 41320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 740 KB Output is correct
2 Correct 563 ms 68428 KB Output is correct
3 Correct 190 ms 25900 KB Output is correct
4 Correct 279 ms 74380 KB Output is correct
5 Correct 385 ms 64492 KB Output is correct