답안 #471331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471331 2021-09-08T12:56:00 Z XII Mobile (BOI12_mobile) C++17
28 / 100
627 ms 8140 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 * 1000 + 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, 2e9, 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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Incorrect 2 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 3 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1004 KB Output is correct
2 Correct 52 ms 844 KB Output is correct
3 Correct 47 ms 992 KB Output is correct
4 Incorrect 41 ms 1100 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 1100 KB Output is correct
2 Correct 65 ms 1100 KB Output is correct
3 Correct 54 ms 1100 KB Output is correct
4 Correct 42 ms 1100 KB Output is correct
5 Incorrect 46 ms 1100 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 1100 KB Output is correct
2 Correct 63 ms 1100 KB Output is correct
3 Correct 56 ms 1100 KB Output is correct
4 Correct 44 ms 1100 KB Output is correct
5 Incorrect 45 ms 1100 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 4172 KB Output is correct
2 Correct 302 ms 4228 KB Output is correct
3 Correct 316 ms 4220 KB Output is correct
4 Incorrect 211 ms 4228 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 4224 KB Output is correct
2 Incorrect 323 ms 4228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 4960 KB Output is correct
2 Correct 363 ms 4940 KB Output is correct
3 Correct 353 ms 4996 KB Output is correct
4 Correct 246 ms 4940 KB Output is correct
5 Correct 268 ms 5004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 389 ms 4940 KB Output is correct
2 Correct 374 ms 5008 KB Output is correct
3 Correct 320 ms 4996 KB Output is correct
4 Incorrect 249 ms 4940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 5708 KB Output is correct
2 Correct 447 ms 5788 KB Output is correct
3 Correct 426 ms 5808 KB Output is correct
4 Incorrect 307 ms 5828 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 448 ms 5780 KB Output is correct
2 Correct 413 ms 5828 KB Output is correct
3 Correct 389 ms 5788 KB Output is correct
4 Correct 290 ms 5800 KB Output is correct
5 Correct 294 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 444 ms 6576 KB Output is correct
2 Correct 491 ms 6580 KB Output is correct
3 Correct 492 ms 6572 KB Output is correct
4 Correct 333 ms 6568 KB Output is correct
5 Incorrect 361 ms 6476 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 560 ms 6596 KB Output is correct
2 Incorrect 502 ms 6568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 565 ms 8140 KB Output is correct
2 Correct 611 ms 8140 KB Output is correct
3 Correct 584 ms 8140 KB Output is correct
4 Correct 412 ms 8140 KB Output is correct
5 Correct 436 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 627 ms 8140 KB Output is correct
2 Correct 580 ms 8140 KB Output is correct
3 Correct 529 ms 8140 KB Output is correct
4 Correct 436 ms 8140 KB Output is correct
5 Incorrect 434 ms 8140 KB Output isn't correct