제출 #1136456

#제출 시각아이디문제언어결과실행 시간메모리
1136456concuaMobile (BOI12_mobile)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 1;
pair<double, double> p[N];

int n, L;

double pre = 0.0;

bool check(double x){
    pre = 0.0; 
    for (int i = 1; i <= n; i++){
        if (x * x < p[i].second * p[i].second{
            return false; 
        }
        
        double delta = sqrt(x * x - p[i].second * p[i].second);

        if (pre > p[i].first - delta){
            
            pre = max(pre, p[i].first + delta);
            
        } 
        else{
            
            pre = p[i].first - delta;
            
        }
    }

    return pre >= L;
}

int main() {
    cin >> n >> L;
    for (int i = 1; i <= n; i++){
        
        cin >> p[i].first >> p[i].second;
        
    }

    double l = 0, r = 1e9 + 1;

    while (r - l > 1e-3){
        
        double mid = (r + l) / 2;

        if (check(mid)){
            r = mid;
        } 
        else{
            l = mid;
        }
        
    }

    cout << fixed << setprecision(4) << r << "\n";

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

mobile.cpp: In function 'bool check(double)':
mobile.cpp:14:46: error: expected ';' before '{' token
   14 |         if (x * x < p[i].second * p[i].second{
      |                                              ^
      |                                              ;
mobile.cpp:18:63: error: expected ')' before ';' token
   18 |         double delta = sqrt(x * x - p[i].second * p[i].second);
      |                                                               ^
      |                                                               )
mobile.cpp:14:12: note: to match this '('
   14 |         if (x * x < p[i].second * p[i].second{
      |            ^
mobile.cpp:20:32: error: 'delta' was not declared in this scope
   20 |         if (pre > p[i].first - delta){
      |                                ^~~~~