답안 #312542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312542 2020-10-13T16:49:08 Z fatemetmhr Balloons (CEOI11_bal) C++17
컴파일 오류
0 ms 0 KB
include<bits/stdc++.h>
#define sanastd using namespace std
sanastd;

const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;

int n, r[MAXN], x[MAXN];
long double ans[MAXN];
stack <int> balloon;

bool check(int ind1, int ind2, double mid)
{
    long double d = (x[ind1] - x[ind2]) * (x[ind1] - x[ind2]) + (ans[ind2] - mid) * (ans[ind2] - mid);
    if(sqrt(d) < mid + ans[ind2]) return 0;
    else return 1;
}
int main ()
{
    cout<<fixed<<setprecision(15);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin >> n >> x[0] >> r[0];
    balloon.push(0);
    ans[0] = r[0];
    cout << r[0] << endl;
    for(int i = 1; i < n; i++){
        cin >> x[i] >> r[i];
        ans[i] = r[i];
        while(!balloon.empty() and r[balloon.top()] <= ans[i]){
            long double lo = 0, hi = ans[i] + 0.001;
            while(hi - lo > 0.001){
                long double mid = (hi + lo) / 2.0;
                if(check(i, balloon.top(), mid)) lo = mid;
                else hi = mid;
            }
            ans[i] = min(ans[i], lo);
            if(ans[i] >= r[balloon.top()) balloon.pop();
        }
        if(!balloon.empty()){
            long double lo = 0, hi = ans[i] + 0.001;
            while(hi - lo > 0.001){
                long double mid = (hi + lo) / 2.0;
                if(check(i, balloon.top(), mid)) lo = mid;
                else hi = mid;
            }
            ans[i] = min(ans[i], lo);
        }
        balloon.push(i);
        cout << ans[i] << '\n';
    }
    return 0;
}

Compilation message

bal.cpp:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
bal.cpp:10:1: error: 'stack' does not name a type
   10 | stack <int> balloon;
      | ^~~~~
bal.cpp: In function 'bool check(int, int, double)':
bal.cpp:15:8: error: 'sqrt' was not declared in this scope
   15 |     if(sqrt(d) < mid + ans[ind2]) return 0;
      |        ^~~~
bal.cpp: In function 'int main()':
bal.cpp:20:5: error: 'cout' was not declared in this scope
   20 |     cout<<fixed<<setprecision(15);
      |     ^~~~
bal.cpp:20:11: error: 'fixed' was not declared in this scope
   20 |     cout<<fixed<<setprecision(15);
      |           ^~~~~
bal.cpp:20:18: error: 'setprecision' was not declared in this scope
   20 |     cout<<fixed<<setprecision(15);
      |                  ^~~~~~~~~~~~
bal.cpp:21:5: error: 'ios_base' has not been declared
   21 |     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
      |     ^~~~~~~~
bal.cpp:21:34: error: 'cin' was not declared in this scope
   21 |     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
      |                                  ^~~
bal.cpp:24:5: error: 'balloon' was not declared in this scope
   24 |     balloon.push(0);
      |     ^~~~~~~
bal.cpp:26:21: error: 'endl' was not declared in this scope
   26 |     cout << r[0] << endl;
      |                     ^~~~
bal.cpp:37:22: error: 'min' was not declared in this scope; did you mean 'main'?
   37 |             ans[i] = min(ans[i], lo);
      |                      ^~~
      |                      main
bal.cpp:38:41: error: expected ']' before ')' token
   38 |             if(ans[i] >= r[balloon.top()) balloon.pop();
      |                                         ^
      |                                         ]
bal.cpp:47:22: error: 'min' was not declared in this scope; did you mean 'main'?
   47 |             ans[i] = min(ans[i], lo);
      |                      ^~~
      |                      main
bal.cpp: In function 'bool check(int, int, double)':
bal.cpp:14:17: warning: control reaches end of non-void function [-Wreturn-type]
   14 |     long double d = (x[ind1] - x[ind2]) * (x[ind1] - x[ind2]) + (ans[ind2] - mid) * (ans[ind2] - mid);
      |                 ^