Submission #1352877

#TimeUsernameProblemLanguageResultExecution timeMemory
1352877vahagngMobile (BOI12_mobile)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define ld long double

struct Point{
    ld x, y;

};

ld dist(Point A, Point B){
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}

struct Line{
    ld k, b;

    Point X_intersect(){
        return Point{-b / k * 1.0, 0.0};
    }
};

Line ln(Point A, Point B){
    // y1 = k*x1 + b
    // y2 = k*x2 + b
    // y1 - y2 = k(x1 - x2)
    // k = (y1 - y2) / (x1 - x2)
    ld K = (A.y - B.y) / (A.x - B.x);
    ld BB = A.y - K*A.x;
    return Line{K, BB};
}

Line mijnuxahayac(Point A, Point B){
    auto [K, BB] = ln(A, B);
    Point M = {(A.x + B.x) / 2.0, (A.y + B.y) / 2.0};
    ld K1 = -1.0 / K;
    ld BB1 = M.y - K1*M.x;
    return Line{K1, BB1};        
}

void precision(int x){
	cout.setf(ios::fixed | ios::showpoint);
	cout.precision(x);
	return;
}

const int N = 1e6 + 10;

int n, l;

Point a[N];

ld eps = 1e-11;

bool check(ld m){
    vector<pair<ld, ld>>A;
    for(int i = 1; i <= n; i++){
        if(a[i].x * a[i].x + eps >= m * m){
            ld d = sqrt(m * m - a[i].y * a[i].y);
            A.push_back({a[i].x - d, a[i].x + d});
        }
    }
    if(A.empty()){
        return 0;
    }
    if(A[0].first - eps > 0){
        return 0;
    }
    if(A.back().second + eps < l){
        return 0;
    }
    for(int i = 1; i < A.size(); i++){
        if(!(A[i - 1].second - eps >= A[i].first)){
            return 0;
        }
    }
    return ;
}

int main(){
    cin >> n >> l;
    for(int i = 1; i <= n; i++){
        cin >> a[i].x >> a[i].y;
    }
    ld l = 0.0, r = 1e10, ans;
    for(int it = 0; it < 100; it++){
        ld m = (l + r) / 2.0;
        if(check(m)){
            r = m - 1;
            ans = m;
        }else{
            l = m + 1;
        }
    }
    precision(20);
    cout << ans << endl;
}

Compilation message (stderr)

mobile.cpp: In function 'bool check(long double)':
mobile.cpp:77:5: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   77 |     return ;
      |     ^~~~~~