Submission #1056895

# Submission time Handle Problem Language Result Execution time Memory
1056895 2024-08-13T12:13:09 Z TimAni Mobile (BOI12_mobile) C++17
13 / 100
1000 ms 40672 KB
// time-limit: 3000
 
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const double eps = 1E-4;
 
struct point {
    int x{}, y{};
};
 
void solve() {
    int n, L;
    cin >> n >> L;
    vector<point> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    auto intersection = [&](const point& A, double R) -> array<double, 2> {
        if(abs(A.y) > R) {
            assert(1);
            return {L, -1};
        }
        double D = 1.0 * R * R - 1.0 * A.y * A.y; // divided by 4
        double x1 = A.x - sqrt(D);
        double x2 = A.x + sqrt(D);
        if(x2 < x1) swap(x1, x2);
        return {x1, x2};
    };
 
    auto good = [&](double R) {
        vector<array<double, 2>> segs;
        for(int i = 0; i < n; i++) {
            if(abs(p[i].y) > R) continue;
            segs.push_back(intersection(p[i], R));
        }
        if(segs.empty()) return false;
        sort(segs.begin(), segs.end());
        double l = segs[0][0], r = segs[0][1];
        int i = 0;
        while(i + 1 < segs.size() && segs[i + 1][0] <= r) {
            r = max(segs[i + 1][1], r);
            i++;
        }
        return r >= L && l <= 0;
    };
 
    double l = 0, r = 4e9;
    while(r - l > eps) {
        double R = (r + l) / 2;
        if(good(R)) {
            r = R;
        }
        else {
            l = R;
        }
        
    }
    cout << fixed << setprecision(-log10(eps)) << r << endl;
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    double T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:24:21: warning: narrowing conversion of 'L' from 'int' to 'double' [-Wnarrowing]
   24 |             return {L, -1};
      |                     ^
mobile.cpp: In lambda function:
mobile.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<double, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         while(i + 1 < segs.size() && segs[i + 1][0] <= r) {
      |               ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 4 ms 588 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 696 KB Output is correct
2 Correct 9 ms 720 KB Output is correct
3 Correct 11 ms 700 KB Output is correct
4 Correct 5 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 700 KB Output is correct
2 Correct 9 ms 716 KB Output is correct
3 Correct 15 ms 700 KB Output is correct
4 Correct 4 ms 716 KB Output is correct
5 Correct 6 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 4368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 4380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 239 ms 4668 KB Output is correct
2 Correct 252 ms 4468 KB Output is correct
3 Correct 277 ms 4528 KB Output is correct
4 Incorrect 63 ms 4816 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 293 ms 4892 KB Output is correct
2 Correct 380 ms 4880 KB Output is correct
3 Correct 383 ms 4908 KB Output is correct
4 Correct 64 ms 4788 KB Output is correct
5 Incorrect 132 ms 4856 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 234 ms 4912 KB Output is correct
2 Correct 346 ms 4888 KB Output is correct
3 Correct 408 ms 4948 KB Output is correct
4 Correct 91 ms 4812 KB Output is correct
5 Incorrect 163 ms 4872 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 20428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 20676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 32924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 32360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 33412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 35416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 37092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 36460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 40488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 40672 KB Time limit exceeded
2 Halted 0 ms 0 KB -