Submission #903916

# Submission time Handle Problem Language Result Execution time Memory
903916 2024-01-11T14:22:26 Z tz74 Mobile (BOI12_mobile) C++17
0 / 100
709 ms 18988 KB
#include <iostream>
#include <vector>
#include <iomanip>
#include <ctgmath>

using namespace std;

using i64 = long long;
using f64 = double;

i64 N;
f64 L;
vector<pair<i64, i64> > towers;

f64 sq(f64 in) {
    return in * in;
}

bool contiguous(f64 R) {
    bool init = false;

    f64 leftmost = -1;
    f64 rightmost = -1;

    for (int i = 0; i < N; i++) {
        f64 x = towers[i].first;
        f64 y = towers[i].second;
        f64 d = sq(2.0 * x) - 4.0 * (sq(x) + sq(y) - sq(R));

        if (d > 0) {
            f64 x1 = (2.0 * x - sqrt(d)) / 2;
            f64 x2 = (2.0 * x + sqrt(d)) / 2;

            // printf("i: %d, x1: %lf, x2: %lf\n", i, x1, x2);

            if (!init) {
                init = true;
                leftmost = x1;
                rightmost = x2;
            } else if (x1 < rightmost) {
                rightmost = x2;
            }
        }
    }

    // printf("leftmost: %lf, rightmost: %lf\n", leftmost, rightmost);
    return leftmost <= 0 && rightmost >= L;
}

int main(void) {
    cin >> N >> L;
    for (int i = 0; i < N; i++) {
        pair<i64, i64> p;
        cin >> p.first >> p.second;
        towers.push_back(p);
    }

    // printf("contiguous: %d\n", contiguous(5.5454));
    // return 0;

    f64 lo = 1.0;
    f64 hi = 1.5e9;

    while (hi - lo > 1e-3) {
        f64 mid = (hi + lo) / 2;

        // we want the largest value where it's not contiguous
        if (contiguous(mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }

    cout << lo << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Incorrect 1 ms 360 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 616 KB Output is correct
2 Incorrect 4 ms 616 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2468 KB Output is correct
2 Incorrect 64 ms 2616 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 326 ms 8888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 378 ms 10424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 345 ms 18816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 420 ms 17412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 370 ms 18988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 505 ms 17376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 424 ms 17940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 614 ms 18880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 512 ms 18608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 709 ms 17688 KB Output isn't correct
2 Halted 0 ms 0 KB -