Submission #1102816

# Submission time Handle Problem Language Result Execution time Memory
1102816 2024-10-19T03:40:48 Z Zero_OP Mobile (BOI12_mobile) C++17
65 / 100
1000 ms 40780 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, l, r) for(int i = (l), _r = (r); i < _r; ++i)
#define FOR(i, l, r) for(int i = (l), _r = (r); i <= _r; ++i)
#define ROF(i, r, l) for(int i = (r), _l = (l); i >= _l; --i)
#define all(v) begin(v), end(v)
#define compact(v) v.erase(unique(all(v)), end(v))
#define sz(v) (int)v.size()
#define dbg(x) "[" #x " = " << (x) << "]"

template<typename T>
bool minimize(T& a, const T& b){
    if(a > b) return a = b, true; return false;
}

template<typename T>
bool maximize(T& a, const T& b){
    if(a < b) return a = b, true; return false;
}

using ll = long long;
using ld = long double;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> T random_int(T l, T r){ return uniform_int_distribution<T>(l, r)(rng); }
template<typename T> T random_real(T l, T r){ return uniform_real_distribution<T>(l, r)(rng); }

const ld eps = 1e-6;

struct point{
    ld x, y;
    point(ld x = 0, ld y = 0) : x(x), y(y) {}

    ld norm() const { return x * x + y * y; }
    ld dist() const { return sqrtl(norm()); }

    friend istream& operator >> (istream& in, point& p) { return in >> p.x >> p.y; }
};

void testcase(){
    int n;
    ld L;
    cin >> n >> L;
    vector<point> points(n);
    for(int i = 0; i < n; ++i) cin >> points[i];

    cout << fixed << setprecision(6);
    ld l = 0, r = sqrt(2e18) + 10;

    int rep = 0;
    while(r - l > eps){
        ld mid = (l + r) / 2.0l;
        ld mid2 = mid * mid;

        ld last_cover = 0.0;
        for(int i = 0; i < n; ++i){
            ld p = points[i].y * points[i].y;
            ld q = sqrtl(mid2 - p);
            ld cover_left = points[i].x - q;
            ld cover_right = points[i].x + q;
            if(cover_left <= last_cover){
                last_cover = max(last_cover, cover_right);
            }
        }

        if(last_cover >= L) r = mid;
        else l = mid;
    }

    cout << fixed << setprecision(6) << l << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #define filename "task"
    if(fopen(filename".inp", "r")){
        freopen(filename".inp", "r", stdin);
        freopen(filename".out", "w", stdout);
    }

    int T = 1; //cin >> T;
    while(T--) testcase();

    return 0;
}

Compilation message

mobile.cpp: In function 'bool minimize(T&, const T&)':
mobile.cpp:15:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   15 |     if(a > b) return a = b, true; return false;
      |     ^~
mobile.cpp:15:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   15 |     if(a > b) return a = b, true; return false;
      |                                   ^~~~~~
mobile.cpp: In function 'bool maximize(T&, const T&)':
mobile.cpp:20:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   20 |     if(a < b) return a = b, true; return false;
      |     ^~
mobile.cpp:20:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   20 |     if(a < b) return a = b, true; return false;
      |                                   ^~~~~~
mobile.cpp: In function 'void testcase()':
mobile.cpp:52:9: warning: unused variable 'rep' [-Wunused-variable]
   52 |     int rep = 0;
      |         ^~~
mobile.cpp: In function 'int main()':
mobile.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen(filename".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(filename".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 592 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 8 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 592 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 7 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 592 KB Output is correct
2 Correct 4 ms 760 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 8 ms 596 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 2640 KB Output is correct
2 Correct 44 ms 3924 KB Output is correct
3 Correct 54 ms 2644 KB Output is correct
4 Correct 115 ms 3848 KB Output is correct
5 Correct 69 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 2896 KB Output is correct
2 Correct 109 ms 3412 KB Output is correct
3 Correct 101 ms 3924 KB Output is correct
4 Correct 102 ms 3936 KB Output is correct
5 Correct 130 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 3152 KB Output is correct
2 Correct 46 ms 2896 KB Output is correct
3 Correct 65 ms 2896 KB Output is correct
4 Correct 187 ms 5352 KB Output is correct
5 Correct 133 ms 4136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3408 KB Output is correct
2 Correct 67 ms 3576 KB Output is correct
3 Correct 70 ms 3408 KB Output is correct
4 Correct 158 ms 5460 KB Output is correct
5 Correct 133 ms 4740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 3408 KB Output is correct
2 Correct 60 ms 3576 KB Output is correct
3 Correct 74 ms 3544 KB Output is correct
4 Correct 170 ms 5508 KB Output is correct
5 Correct 140 ms 4684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 295 ms 15952 KB Output is correct
2 Correct 316 ms 15952 KB Output is correct
3 Correct 325 ms 15952 KB Output is correct
4 Correct 709 ms 15952 KB Output is correct
5 Correct 610 ms 22776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 15952 KB Output is correct
2 Correct 597 ms 15952 KB Output is correct
3 Correct 416 ms 21876 KB Output is correct
4 Correct 806 ms 25328 KB Output is correct
5 Correct 733 ms 23408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 388 ms 19024 KB Output is correct
2 Correct 361 ms 19024 KB Output is correct
3 Correct 345 ms 19024 KB Output is correct
4 Execution timed out 1028 ms 19024 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 364 ms 19024 KB Output is correct
2 Correct 847 ms 19024 KB Output is correct
3 Correct 480 ms 25896 KB Output is correct
4 Correct 895 ms 30796 KB Output is correct
5 Correct 820 ms 27724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 412 ms 22352 KB Output is correct
2 Correct 396 ms 22272 KB Output is correct
3 Correct 512 ms 22352 KB Output is correct
4 Execution timed out 1061 ms 22264 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 490 ms 22352 KB Output is correct
2 Correct 869 ms 22352 KB Output is correct
3 Correct 572 ms 30540 KB Output is correct
4 Execution timed out 1056 ms 35660 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 478 ms 25592 KB Output is correct
2 Correct 448 ms 25424 KB Output is correct
3 Correct 460 ms 25424 KB Output is correct
4 Execution timed out 1055 ms 25424 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 474 ms 25424 KB Output is correct
2 Correct 884 ms 25424 KB Output is correct
3 Correct 561 ms 35024 KB Output is correct
4 Execution timed out 1068 ms 40780 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 600 ms 31568 KB Output is correct
2 Correct 572 ms 31568 KB Output is correct
3 Correct 606 ms 31568 KB Output is correct
4 Execution timed out 1082 ms 31568 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 595 ms 31568 KB Output is correct
2 Execution timed out 1069 ms 31740 KB Time limit exceeded
3 Halted 0 ms 0 KB -