Submission #1092972

# Submission time Handle Problem Language Result Execution time Memory
1092972 2024-09-25T14:41:41 Z TommasoUlian Mobile (BOI12_mobile) C++14
0 / 100
782 ms 32520 KB
#include <bits/stdc++.h>
#define PB push_back
#define MP makepair
#ifndef ONLINE_JUDGE
#define DEBUG(x) cout << #x << " = " << (x) << endl
#else
#define DEBUG(x)
#endif
#define FOR(n) for(int i = 0; i < (n); i++)
#define SORTA(v) sort((v).begin(), (v).end())
#define SORTD(v) sort((v).rbegin(), (v).rend())
#define PRINT(v) for(auto x: (v))cout << x << " "; cout << endl;
#define TWO(n) (1 << (n))
#define INPUT(v) for(auto &x : (v))cin >> x;
#pragma GCC optimize("Ofast,no-stack-protector",3)

typedef long long ll;

using namespace std;

vector<pair<double,double>> torri;
ll n,L;

bool good(double r){
    queue<pair<double,double>> s;
    
    for(auto [x,y]:torri){
        if(r*r >= y*y)s.push({max(0.0,x-sqrt(r*r-y*y)),min((double)L,x+sqrt(r*r-y*y))});
    }
    double curr = 0;
    while(!s.empty()){
        auto seg = s.front();
        s.pop();
        if(seg.first <= curr){
            curr = seg.second;
        }
        else return false;
    }
    if(curr < L)return false;
    return true;
}

void solve(){
    cin >> n >> L;
    torri = vector<pair<double,double>>(n);
    for(int i = 0; i < n; i++){
        cin >> torri[i].first >> torri[i].second;

    }
    double l = 0, r = 20e9;
    double ans = r;
    
    while(r-l >= 0.00001){
        double c = (l + (r-l)/2);
        //cout << c << endl;
        if(good(c)){
            ans = min(ans,c);
            r = c;
        }
        else{
            l = c;
        }

    }
    cout << ans << endl;
    
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    solve();
    return 0;
}

Compilation message

mobile.cpp: In function 'bool good(double)':
mobile.cpp:27:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |     for(auto [x,y]:torri){
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 2844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 3128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3384 KB Output is correct
2 Incorrect 57 ms 3092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 3768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 3792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 356 ms 16592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 383 ms 16652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 457 ms 19800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 448 ms 19772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 500 ms 22976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 522 ms 22996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 584 ms 26260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 613 ms 26156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 730 ms 32516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 782 ms 32520 KB Output isn't correct
2 Halted 0 ms 0 KB -