Submission #471346

# Submission time Handle Problem Language Result Execution time Memory
471346 2021-09-08T13:52:44 Z XII Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 40384 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);
    }
}

double SQ(const double &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;
        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:67:9: note: in expansion of macro 'FOR'
   67 |         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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 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 4 ms 332 KB Output is correct
2 Runtime error 4 ms 696 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 556 KB Output is correct
2 Correct 10 ms 556 KB Output is correct
3 Correct 13 ms 572 KB Output is correct
4 Correct 6 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 4216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 152 ms 4224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 212 ms 4712 KB Output is correct
2 Correct 302 ms 4380 KB Output is correct
3 Correct 343 ms 4392 KB Output is correct
4 Incorrect 92 ms 4656 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 276 ms 4748 KB Output is correct
2 Correct 387 ms 4780 KB Output is correct
3 Correct 404 ms 4756 KB Output is correct
4 Correct 89 ms 4700 KB Output is correct
5 Incorrect 162 ms 4748 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 4752 KB Output is correct
2 Correct 395 ms 4756 KB Output is correct
3 Correct 436 ms 4828 KB Output is correct
4 Correct 93 ms 4832 KB Output is correct
5 Incorrect 159 ms 4736 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 20424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 20432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 31016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 30980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 33376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 33336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 35848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 35712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 40384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 40336 KB Time limit exceeded
2 Halted 0 ms 0 KB -