답안 #481799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481799 2021-10-22T00:06:25 Z sberens Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 81728 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<int, 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;
    vll x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }

    cout << 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';

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 604 KB Output is correct
2 Correct 18 ms 604 KB Output is correct
3 Correct 8 ms 448 KB Output is correct
4 Incorrect 15 ms 608 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 840 KB Output is correct
2 Incorrect 38 ms 1008 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1012 KB Output is correct
2 Incorrect 38 ms 952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 844 KB Output is correct
2 Incorrect 46 ms 888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 499 ms 8776 KB Output is correct
2 Incorrect 812 ms 9136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 491 ms 9008 KB Output is correct
2 Correct 398 ms 8704 KB Output is correct
3 Incorrect 428 ms 9296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 820 ms 9388 KB Output is correct
2 Incorrect 893 ms 9676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 937 ms 10796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 894 ms 10816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 44596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 48548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 64268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 68872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 66692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 72148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 69236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 75344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 74152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 81728 KB Time limit exceeded
2 Halted 0 ms 0 KB -