답안 #623053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
623053 2022-08-05T06:38:23 Z 54skyxenon Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 40300 KB
// https://oj.uz/problem/view/BOI12_mobile

#include <bits/stdc++.h>
using namespace std;

#define EPS 0.0001
#define pdd pair<double, double>
#define mp make_pair

int n, l;
vector<int> X, Y;

vector<pdd> merge(vector<pdd>& intervals) {
    sort(intervals.begin(), intervals.end());

    vector<pdd> new_intervals;
    for (auto [start, end] : intervals) {
        if (new_intervals.empty() || new_intervals.rbegin()->second < start) {
            new_intervals.push_back(mp(start, end));
        }
        else {
            new_intervals.rbegin()->second = max(new_intervals.rbegin()->second, end);
        }
    }
    
    return new_intervals;
}

bool ok(double radius) {
    vector<pdd> intervals({mp(0, 0), mp(l, l)});
    
    for (int i = 0; i < n; i++) {
        double x1 = X[i], y1 = Y[i];
    
        double term = (radius * radius) - (y1 * y1);
        if (term >= 0) {
            double term_sqrt = sqrt(term);
            intervals.push_back(mp(x1 - term_sqrt, x1 + term_sqrt));
        }
    }
        
    intervals = merge(intervals);

    for (int i = 0; i < intervals.size() - 1; i++) {
        double midpt = (intervals[i].second + intervals[i + 1].first) / 2;
        if (0 <= midpt && midpt <= l) {
            return true;
        }
    }

    return false;
}

int main() {
    cin >> n >> l;

    X.resize(n);
    Y.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> X[i] >> Y[i];
    }

    double lo = 0.0;
    double hi = l;

    int threshold = 100;
    while (threshold--) {
        double mid = (lo + hi) / 2;

        if (!ok(mid)) {
            hi = mid;
        }
        else {
            lo = mid;
        }
    }

    cout << lo << endl;
}

Compilation message

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < intervals.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 8 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 12 ms 416 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Incorrect 18 ms 536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 448 KB Output is correct
2 Incorrect 21 ms 920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 548 KB Output is correct
2 Incorrect 20 ms 552 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 288 ms 4160 KB Output is correct
2 Incorrect 590 ms 4396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 2044 KB Output is correct
2 Correct 59 ms 2116 KB Output is correct
3 Incorrect 66 ms 2076 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 825 ms 4452 KB Output is correct
2 Incorrect 662 ms 4344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 641 ms 4816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 779 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 20264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 20512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 30896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1082 ms 30944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 33244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 33224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 35660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 35656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 40244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 40300 KB Time limit exceeded
2 Halted 0 ms 0 KB -