Submission #1281552

#TimeUsernameProblemLanguageResultExecution timeMemory
1281552minhphanMobile (BOI12_mobile)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

bool covers(vector<pair<int, int>> &pair, int N, double rSq, double L) {
    double covered = 0;
    for (int i = 0; i<N; i++) {
        const double deltaX = sqrt(rSq - pair[i].second*pair[i].second);
        const double a = pair[i].first - deltaX;
        double b = pair[i].first + deltaX;
        if (a <= covered) {
            covered = max(covered, b);
        }
    }
    return covered >= L;
}

int main() {
    int N, L;
    cin >> N >> L;

    vector<pair<long long, long long>> pair(N);
    for (int i = 0; i<N; i++) {
        cin >> pair[i].first >> pair[i].second;
    }

    double low = 1;
    double high = 1.5e9;

    while (high - low > 1e-3) {
        const double m = (low+high)/2;

        if (covers(pair, N, m*m, L)) {
            high = m;
        } else {
            low = m;
        }
    }

    cout << fixed << setprecision(4) << low;
    return 0;
}

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:33:20: error: invalid initialization of reference of type 'std::vector<std::pair<int, int> >&' from expression of type 'std::vector<std::pair<long long int, long long int> >'
   33 |         if (covers(pair, N, m*m, L)) {
      |                    ^~~~
mobile.cpp:5:37: note: in passing argument 1 of 'bool covers(std::vector<std::pair<int, int> >&, int, double, double)'
    5 | bool covers(vector<pair<int, int>> &pair, int N, double rSq, double L) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~