답안 #471342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471342 2021-09-08T13:48:22 Z XII Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 48104 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 T(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<double> 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;
        vector<pair<double, double>> range;
        FOR(i, 0, n) if(abs(y[i]) <= r){
            double D = sqrt(SQ(r) - SQ(y[i]));
            range.eb(x[i] - D, x[i] + D);
//            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);
//            }
        }
        sort(ALL(range));
        double L = range[0].fi, R = range[0].se;
        FOR(i, 1, range.size()){
            if(range[i].fi <= R) R = max(R, range[i].se);
        }
        return (L <= 0 && l <= R);
    };

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

    return 0;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:12:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 | #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
mobile.cpp:68:9: note: in expansion of macro 'FOR'
   68 |         FOR(i, 1, range.size()){
      |         ^~~
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 1 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 5 ms 460 KB Output is correct
2 Runtime error 4 ms 716 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 612 KB Output is correct
2 Correct 11 ms 616 KB Output is correct
3 Correct 16 ms 688 KB Output is correct
4 Correct 9 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 119 ms 4792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 172 ms 4828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 223 ms 5228 KB Output is correct
2 Correct 312 ms 4964 KB Output is correct
3 Correct 367 ms 5100 KB Output is correct
4 Incorrect 128 ms 5420 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 318 ms 5624 KB Output is correct
2 Correct 434 ms 5524 KB Output is correct
3 Correct 439 ms 5536 KB Output is correct
4 Correct 131 ms 5520 KB Output is correct
5 Incorrect 193 ms 5512 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 285 ms 5660 KB Output is correct
2 Correct 427 ms 5616 KB Output is correct
3 Correct 444 ms 5560 KB Output is correct
4 Correct 135 ms 5428 KB Output is correct
5 Incorrect 192 ms 5536 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 24328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 24268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 35612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 35656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 38760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 38680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 41832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 41924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1101 ms 48104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 47992 KB Time limit exceeded
2 Halted 0 ms 0 KB -