Submission #471336

# Submission time Handle Problem Language Result Execution time Memory
471336 2021-09-08T13:10:34 Z XII Mobile (BOI12_mobile) C++17
28 / 100
681 ms 8260 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define ALL(x) (x).begin(), (x).end()

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORU(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define IOS cin.tie(0)->sync_with_stdio(false);
#define PROB "BOI12_mobile"
void Fi(){
    if(fopen(PROB".inp", "r")){
        freopen(PROB".inp", "r", stdin);
        freopen(PROB".out", "w", stdout);
    }
}

template<typename T>
T SQ(const T &x){
    return x * x;
}

const ll NONE = -2e18;

ll Round(const double &x){
    return (x * 10000 + 0.5);
}

double firstTrue(double lo, double hi, function<bool(double)> f){
    while(Round(lo) < Round(hi)){
        double mid = lo + (hi - lo) / 2;
        if(f(mid)) hi = mid;
        else lo = mid;
    }
    return hi;
}

int main(){
    IOS;
    Fi();
    int n, l; cin >> n >> l;
    vector<int> x(n), y(n);
    FOR(i, 0, n) cin >> x[i] >> y[i];

    const auto check = [&](const double &r) -> bool{
        double L = NONE, R = NONE;
        FOR(i, 0, n) if(abs(y[i]) <= r){
            double D = sqrt(SQ(r) - SQ(1LL * y[i]));
            if(L == NONE && R == NONE){
                L = x[i] - D;
                R = x[i] + D;
            } else{
                L = min(L, x[i] - D);
                if(x[i] - D <= R) R = max(R, x[i] + D);
            }
        }
        return (L <= 0 && l <= R);
    };

    cout << fixed << setprecision(3) << firstTrue(0, 3e9, check);

    return 0;
}

Compilation message

mobile.cpp: In function 'void Fi()':
mobile.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(PROB".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(PROB".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 352 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 55 ms 992 KB Output is correct
2 Correct 56 ms 844 KB Output is correct
3 Correct 48 ms 972 KB Output is correct
4 Incorrect 44 ms 1100 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 1100 KB Output is correct
2 Correct 69 ms 1104 KB Output is correct
3 Correct 59 ms 1100 KB Output is correct
4 Correct 43 ms 1100 KB Output is correct
5 Incorrect 46 ms 1100 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1100 KB Output is correct
2 Correct 64 ms 1100 KB Output is correct
3 Correct 59 ms 1100 KB Output is correct
4 Correct 43 ms 1108 KB Output is correct
5 Incorrect 46 ms 1100 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 4224 KB Output is correct
2 Correct 334 ms 4224 KB Output is correct
3 Correct 327 ms 4236 KB Output is correct
4 Incorrect 221 ms 4172 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 337 ms 4292 KB Output is correct
2 Incorrect 352 ms 4224 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 349 ms 4940 KB Output is correct
2 Correct 396 ms 5004 KB Output is correct
3 Correct 393 ms 5048 KB Output is correct
4 Correct 251 ms 4996 KB Output is correct
5 Correct 277 ms 5016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 400 ms 5000 KB Output is correct
2 Correct 407 ms 5012 KB Output is correct
3 Correct 331 ms 4940 KB Output is correct
4 Incorrect 253 ms 4940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 420 ms 5800 KB Output is correct
2 Correct 448 ms 5788 KB Output is correct
3 Correct 443 ms 5708 KB Output is correct
4 Incorrect 303 ms 5828 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 472 ms 5708 KB Output is correct
2 Correct 458 ms 5788 KB Output is correct
3 Correct 390 ms 5788 KB Output is correct
4 Correct 308 ms 5788 KB Output is correct
5 Correct 311 ms 5788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 475 ms 6568 KB Output is correct
2 Correct 530 ms 6576 KB Output is correct
3 Correct 520 ms 6572 KB Output is correct
4 Correct 348 ms 6584 KB Output is correct
5 Incorrect 361 ms 6584 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 547 ms 6576 KB Output is correct
2 Incorrect 521 ms 6596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 576 ms 8140 KB Output is correct
2 Correct 645 ms 8260 KB Output is correct
3 Correct 642 ms 8140 KB Output is correct
4 Correct 437 ms 8140 KB Output is correct
5 Correct 446 ms 8152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 681 ms 8140 KB Output is correct
2 Correct 656 ms 8140 KB Output is correct
3 Correct 596 ms 8260 KB Output is correct
4 Correct 438 ms 8140 KB Output is correct
5 Incorrect 439 ms 8140 KB Output isn't correct