Submission #990602

# Submission time Handle Problem Language Result Execution time Memory
990602 2024-05-30T17:07:14 Z Ska Mobile (BOI12_mobile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5 + 5;
 
int n;
long double m;
long double x[N], y[N];
 
pair<long double, long double> calc(long double r, int i) {
    if (r < abs(y[i]) {
        return {-1, -1};
    }
    return {x[i] - sqrtl(r * r - y[i] * y[i]), x[i] + sqrtl(r * r - y[i] * y[i])};
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    long double l = 2e9, r = 2e9;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        l = min(l, abs(y[i]));
    }
    int iter = 50;
    while (iter--) {
        vector<pair<long double, long double>> segments;
        long double mid = (l + r) / 2;
        for (int i = 1; i <= n; ++i) {
            auto x = calc(mid, i);
            if (x.first != -1 || x.second != -1) {
                segments.emplace_back(x.first, x.second);
            }
        }
        sort(segments.begin(), segments.end());
        long double bound = 0;
        for (auto x : segments) {
            if (x.first > bound) {
                break;
            }
            bound = max(bound, x.second);
            if (bound >= m) {
                break;
            }
        }
        if (bound >= m) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << fixed << setprecision(6) << l << '\n';
}

Compilation message

mobile.cpp: In function 'std::pair<long double, long double> calc(long double, int)':
mobile.cpp:11:9: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
   11 |     if (r < abs(y[i]) {
      |         ^
mobile.cpp:11:22: error: expected ';' before '{' token
   11 |     if (r < abs(y[i]) {
      |                      ^~
      |                      ;
mobile.cpp:11:11: warning: value computed is not used [-Wunused-value]
   11 |     if (r < abs(y[i]) {
      |         ~~^~~~~~~~~~~
mobile.cpp:14:5: error: expected primary-expression before 'return'
   14 |     return {x[i] - sqrtl(r * r - y[i] * y[i]), x[i] + sqrtl(r * r - y[i] * y[i])};
      |     ^~~~~~
mobile.cpp:13:6: error: expected ')' before 'return'
   13 |     }
      |      ^
      |      )
   14 |     return {x[i] - sqrtl(r * r - y[i] * y[i]), x[i] + sqrtl(r * r - y[i] * y[i])};
      |     ~~~~~~
mobile.cpp:11:8: note: to match this '('
   11 |     if (r < abs(y[i]) {
      |        ^
mobile.cpp:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
   15 | }
      | ^