Submission #286563

# Submission time Handle Problem Language Result Execution time Memory
286563 2020-08-30T14:37:00 Z __SIGSEGV__ Mobile (BOI12_mobile) C++17
100 / 100
883 ms 47328 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(x,a)           for(int x = 0; x < a; x++)
#define REP(x,a,b)         for(int x = a; x < b; x++)
#define per(x,b)           for(int x = b; x >= 0; x--)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif

const double eps = 1e-3;
const double EPS = 1e-9;

bool eq(double a, double b) {
    return abs(a-b) <= eps;
}

int main(void)
{
    int n;
    double last;
    scanf("%d%lf", &n, &last);
    vector<pair<double, double>> points(n);
    rep(i,n) scanf("%lf%lf", &points[i].fi, &points[i].sc);
    vector<pair<double, double>> poi;
    rep(i,n) {
        poi.emplace_back(points[i]);
        ++i;
        while (i < n && eq(points[i].fi, poi.back().fi)) ++i;
        --i;
    }
    auto Can = [&](double dist) {
        double r = 0.0;
        rep(i,n) {
            double delta = sqrt(dist*dist-points[i].sc*points[i].sc);
            double L = points[i].fi-delta, R = points[i].fi+delta;
            if (L <= r) smax(r, R);
        }
        return (r >= last);
    };
    double l = 0.0, r = 1e10;
    while (r-l > eps) {
        double mid = (r+l)/2.0;
        if (Can(mid)) r = mid;
        else l = mid;
    }
    printf("%.6lf\n", l);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |     scanf("%d%lf", &n, &last);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
mobile.cpp:42:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |     rep(i,n) scanf("%lf%lf", &points[i].fi, &points[i].sc);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 372 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4460 KB Output is correct
2 Correct 48 ms 3700 KB Output is correct
3 Correct 34 ms 2928 KB Output is correct
4 Correct 62 ms 4844 KB Output is correct
5 Correct 32 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2432 KB Output is correct
2 Correct 53 ms 3440 KB Output is correct
3 Correct 63 ms 4844 KB Output is correct
4 Correct 78 ms 4972 KB Output is correct
5 Correct 73 ms 5356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 4592 KB Output is correct
2 Correct 50 ms 3956 KB Output is correct
3 Correct 53 ms 4844 KB Output is correct
4 Correct 91 ms 5996 KB Output is correct
5 Correct 70 ms 3316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 4592 KB Output is correct
2 Correct 68 ms 4464 KB Output is correct
3 Correct 60 ms 3448 KB Output is correct
4 Correct 93 ms 5996 KB Output is correct
5 Correct 81 ms 5356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 5612 KB Output is correct
2 Correct 58 ms 4464 KB Output is correct
3 Correct 59 ms 3320 KB Output is correct
4 Correct 90 ms 5996 KB Output is correct
5 Correct 79 ms 5364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 20836 KB Output is correct
2 Correct 297 ms 13560 KB Output is correct
3 Correct 291 ms 13560 KB Output is correct
4 Correct 453 ms 20812 KB Output is correct
5 Correct 396 ms 21604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 300 ms 16760 KB Output is correct
2 Correct 421 ms 21604 KB Output is correct
3 Correct 313 ms 15596 KB Output is correct
4 Correct 436 ms 21092 KB Output is correct
5 Correct 399 ms 21476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 330 ms 31620 KB Output is correct
2 Correct 367 ms 14584 KB Output is correct
3 Correct 359 ms 14584 KB Output is correct
4 Correct 539 ms 34656 KB Output is correct
5 Correct 463 ms 23140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 356 ms 17272 KB Output is correct
2 Correct 468 ms 30816 KB Output is correct
3 Correct 366 ms 16748 KB Output is correct
4 Correct 532 ms 34272 KB Output is correct
5 Correct 481 ms 30560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 34020 KB Output is correct
2 Correct 404 ms 16120 KB Output is correct
3 Correct 429 ms 14968 KB Output is correct
4 Correct 638 ms 36576 KB Output is correct
5 Correct 560 ms 23140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 425 ms 17656 KB Output is correct
2 Correct 539 ms 31008 KB Output is correct
3 Correct 422 ms 17260 KB Output is correct
4 Correct 646 ms 35680 KB Output is correct
5 Correct 556 ms 31204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 434 ms 35808 KB Output is correct
2 Correct 491 ms 20216 KB Output is correct
3 Correct 482 ms 20344 KB Output is correct
4 Correct 715 ms 35552 KB Output is correct
5 Correct 624 ms 27620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 475 ms 17932 KB Output is correct
2 Correct 630 ms 34376 KB Output is correct
3 Correct 488 ms 17476 KB Output is correct
4 Correct 715 ms 35040 KB Output is correct
5 Correct 637 ms 35808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 540 ms 38112 KB Output is correct
2 Correct 584 ms 19448 KB Output is correct
3 Correct 591 ms 18360 KB Output is correct
4 Correct 883 ms 33760 KB Output is correct
5 Correct 817 ms 37884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 589 ms 17400 KB Output is correct
2 Correct 779 ms 33632 KB Output is correct
3 Correct 616 ms 21484 KB Output is correct
4 Correct 882 ms 33376 KB Output is correct
5 Correct 849 ms 47328 KB Output is correct