Submission #481801

# Submission time Handle Problem Language Result Execution time Memory
481801 2021-10-22T00:20:59 Z sberens Mobile (BOI12_mobile) C++17
30 / 100
1000 ms 80924 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename K> using hset = gp_hash_table<K, null_type>;
template <typename K, typename V> using hmap = gp_hash_table<K, V>;


using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define smax(x, y) (x = max(x, y))
#define smin(x, y) (x = min(x, y))

using ld = long double;
using ll = long long;

template <typename T>
using vv = vector<vector<T>>;

using vi = vector<int>;
using ii = array<int, 2>;
using vii = vector<ii>;
using vvi = vv<int>;

using vll = vector<ll>;
using l2 = array<ll, 2>;
using vl2 = vector<l2>;
using vvll = vv<ll>;

template <typename T>
using minq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxq = priority_queue<T>;

const ll M = 1000000007;

#ifndef REFERENCE_DISCRETE_BINARY_SEARCH_H
#define REFERENCE_DISCRETE_BINARY_SEARCH_H


#include <iostream>
#include <functional>


template<typename IN>
IN discrete_binary_search(function<bool(IN)> predicate, IN low = 0, IN high = numeric_limits<IN>::max()) {
    while (fabs(high - low) > 1e-6) {
        IN middle = low + (high - low) / 2; // todo std::midpoint in cpp 2020
        if (predicate(middle))
            high = middle;
        else low = middle;
    }
    return low;
}

#endif //REFERENCE_DISCRETE_BINARY_SEARCH_H

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    vl2 yx;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        yx.pb({y, x});
    }
    sort(all(yx));
    vll x(n), y(n);
    for (int i = 0; i < n; ++i) {
        x[i] = yx[i][1];
        y[i] = yx[i][0];
    }


    cout << fixed << setprecision(5) << discrete_binary_search<ld>([&](ld d) -> bool {
        // is there a point with min distance > d
        // equivalently, is every point within distance d

        vector<array<ld, 2>> intervals;
        // add to intervals
        for (int i = 0; i < n; ++i) {
            if (abs(y[i]) > d) continue;
            ld dx = sqrt(d * d - y[i] * y[i]);
            intervals.pb({x[i] - dx, x[i] + dx});
        }
        // merge intervals
        sort(all(intervals));
        vector<array<ld, 2>> merged;
        for (auto [s, e] : intervals) {
            if (!merged.empty() && s <= merged.back()[1]) smax(merged.back()[1], e);
            else merged.pb({s, e});
        }
        // check interval spans whole highway
        return any_of(all(merged), [&](array<ld, 2> interval) -> bool {return interval[0] <= 0 && interval[1] >= l;});

    }, 0, 2e15) << '\n';

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 636 KB Output is correct
2 Correct 26 ms 876 KB Output is correct
3 Correct 17 ms 460 KB Output is correct
4 Correct 30 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 920 KB Output is correct
2 Correct 53 ms 1064 KB Output is correct
3 Correct 43 ms 1016 KB Output is correct
4 Correct 39 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 920 KB Output is correct
2 Correct 54 ms 920 KB Output is correct
3 Correct 43 ms 844 KB Output is correct
4 Correct 31 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 928 KB Output is correct
2 Correct 65 ms 844 KB Output is correct
3 Correct 46 ms 928 KB Output is correct
4 Correct 31 ms 916 KB Output is correct
5 Correct 39 ms 920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 809 ms 9128 KB Output is correct
2 Execution timed out 1089 ms 9344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 794 ms 9648 KB Output is correct
2 Correct 636 ms 8888 KB Output is correct
3 Correct 740 ms 9796 KB Output is correct
4 Correct 657 ms 9488 KB Output is correct
5 Correct 609 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 838 ms 10124 KB Output is correct
2 Execution timed out 1055 ms 9680 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 10716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 10776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 48072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 48088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 68640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 68368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 71628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 71452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 74684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 74628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 80924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 80816 KB Time limit exceeded
2 Halted 0 ms 0 KB -