답안 #732390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732390 2023-04-29T03:30:19 Z uy842003 Mobile (BOI12_mobile) C++17
20 / 100
1000 ms 40228 KB
#include <bits/stdc++.h>
using namespace std;

const double eps = 1e-4;

bool cmp_less(double a, double b) {
    return a + eps < b;
}

bool cmp_less_equal(double a, double b) {
    return a < b + eps;
}

bool cmp_range(const pair<double, double> &p1, const pair<double, double> &p2) {
    return cmp_less(p1.first, p2.first);
}

int main() {

    int n;
    double len;
    cin >> n >> len;
    // pair<double, double> *cor = new pair<double, double>[n];
    vector<pair<int, int>> cor(n);
    for (int i = 0; i < n; i++)
        cin >> cor[i].first >> cor[i].second;
    double l = 0, r = 2e9 + 7, m;
    while (cmp_less(l, r)) {
        m = (l + r) / 2;
        vector<pair<double, double>> range, real_range;
        for (int i = 0; i < n; i++) {
            if (cmp_less_equal(m, abs(cor[i].second))) continue;
            double dx = sqrt(m * m - cor[i].second * cor[i].second);
            range.push_back({cor[i].first - dx, cor[i].first + dx});
        }
        sort(range.begin(), range.end(), cmp_range);
        pair<double, double> cur_range = {-1, -1};
        if (range.size() > 0) cur_range = *range.begin();
        for (int i = 0; i < range.size(); i++) {
            if (cmp_less_equal(range[i].first, cur_range.second) && cmp_less(cur_range.second, range[i].second))
                cur_range.second = range[i].second;
            if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
                real_range.push_back(cur_range);
                cur_range = range[i];
            }
        }
        bool iok = false;
        for (int i = 0; i < real_range.size(); i++) {
            if (cmp_less_equal(real_range[i].first, 0) && cmp_less_equal(len, real_range[i].second)) {
                iok = true;
                break;
            }
        }
        if (iok)
            r = m;
        else
            l = m + eps;
    }
    cout << setprecision(3) << fixed;
    cout << r << endl;

    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i = 0; i < range.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~
mobile.cpp:42:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
      |                                                                      ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:48:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int i = 0; i < real_range.size(); 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 1 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 7 ms 340 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 9 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 612 KB Output is correct
2 Correct 17 ms 552 KB Output is correct
3 Correct 17 ms 548 KB Output is correct
4 Correct 10 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 648 KB Output is correct
2 Correct 19 ms 556 KB Output is correct
3 Correct 19 ms 556 KB Output is correct
4 Correct 8 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 556 KB Output is correct
2 Correct 18 ms 548 KB Output is correct
3 Correct 21 ms 544 KB Output is correct
4 Incorrect 7 ms 548 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 4144 KB Output is correct
2 Incorrect 358 ms 4184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 4204 KB Output is correct
2 Correct 171 ms 4000 KB Output is correct
3 Correct 176 ms 4256 KB Output is correct
4 Correct 139 ms 4236 KB Output is correct
5 Incorrect 128 ms 4388 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 370 ms 4432 KB Output is correct
2 Incorrect 410 ms 4432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 463 ms 4728 KB Output is correct
2 Incorrect 526 ms 4812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 4840 KB Output is correct
2 Incorrect 495 ms 4796 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 20292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1047 ms 20268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 30920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 30836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 33192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 33196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 35576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 35668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 40228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 40196 KB Time limit exceeded
2 Halted 0 ms 0 KB -