Submission #1056911

# Submission time Handle Problem Language Result Execution time Memory
1056911 2024-08-13T12:20:37 Z TimAni Mobile (BOI12_mobile) C++17
13 / 100
1000 ms 23892 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) {
            return {1e10, -1e10};
        }
        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(n);
        for(int i = 0; i < n; i++) {
            segs[i] = 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:41: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]
   41 |         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 1 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 4 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 5 ms 500 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 8 ms 348 KB Output is correct
4 Correct 8 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Correct 7 ms 572 KB Output is correct
4 Correct 8 ms 348 KB Output is correct
5 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 2212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 151 ms 2192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 101 ms 2508 KB Output is correct
2 Correct 174 ms 2392 KB Output is correct
3 Correct 177 ms 2392 KB Output is correct
4 Incorrect 194 ms 2772 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 172 ms 2648 KB Output is correct
2 Correct 234 ms 2648 KB Output is correct
3 Correct 204 ms 2652 KB Output is correct
4 Correct 208 ms 2652 KB Output is correct
5 Incorrect 197 ms 2652 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 2652 KB Output is correct
2 Correct 233 ms 2652 KB Output is correct
3 Correct 212 ms 2652 KB Output is correct
4 Correct 187 ms 2648 KB Output is correct
5 Incorrect 210 ms 2648 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 643 ms 12184 KB Output is correct
2 Execution timed out 1029 ms 12112 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 12116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 820 ms 14516 KB Output is correct
2 Execution timed out 1041 ms 14512 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 14536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 917 ms 16788 KB Output is correct
2 Execution timed out 1089 ms 16788 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 16788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 19064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 19068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 23892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 23892 KB Time limit exceeded
2 Halted 0 ms 0 KB -