답안 #471338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471338 2021-09-08T13:35:55 Z XII Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 40412 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<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;
        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 0 ms 204 KB Output is correct
3 Correct 0 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 332 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 8 ms 556 KB Output is correct
2 Correct 10 ms 556 KB Output is correct
3 Correct 13 ms 556 KB Output is correct
4 Correct 6 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 107 ms 4264 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 4220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 4516 KB Output is correct
2 Incorrect 277 ms 4312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 267 ms 4748 KB Output is correct
2 Incorrect 358 ms 4740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 233 ms 4756 KB Output is correct
2 Incorrect 360 ms 4728 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 20336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 20356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 30956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 30996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 33216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 33216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 35676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 35664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 40412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 40332 KB Time limit exceeded
2 Halted 0 ms 0 KB -