Submission #903918

# Submission time Handle Problem Language Result Execution time Memory
903918 2024-01-11T14:29:49 Z tz74 Mobile (BOI12_mobile) C++17
0 / 100
709 ms 18892 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 = -1e10;
    f64 rightmost = -1e10;

    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 = max(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(7.9));
    // 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 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 500 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Incorrect 3 ms 564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Incorrect 6 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 2512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 2496 KB Output is correct
2 Incorrect 81 ms 2600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 2740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 2496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 10252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 352 ms 10580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 322 ms 16948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 438 ms 18892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 374 ms 18860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 470 ms 18676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 481 ms 18208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 559 ms 17656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 566 ms 17112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 709 ms 18096 KB Output isn't correct
2 Halted 0 ms 0 KB -