답안 #1102815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102815 2024-10-19T03:33:27 Z Zero_OP Mobile (BOI12_mobile) C++14
0 / 100
587 ms 50764 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;
            if(mid2 - p < eps) break;
            ld q = sqrtl(mid2 - p);
            ld cover_left = points[i].x - q;
            ld cover_right = points[i].x + q;
            if(last_cover - cover_left > eps){
                last_cover = max(last_cover, cover_right);
            }
        }

        bool ok = last_cover - L > eps;

        if(ok) 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:51:9: warning: unused variable 'rep' [-Wunused-variable]
   51 |     int rep = 0;
      |         ^~~
mobile.cpp: In function 'int main()':
mobile.cpp:83:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |         freopen(filename".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(filename".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 5 ms 592 KB Output is correct
3 Incorrect 3 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3152 KB Output is correct
2 Correct 45 ms 4180 KB Output is correct
3 Incorrect 41 ms 4016 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3408 KB Output is correct
2 Correct 52 ms 4948 KB Output is correct
3 Incorrect 39 ms 4436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 3408 KB Output is correct
2 Correct 55 ms 5000 KB Output is correct
3 Incorrect 43 ms 4436 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 274 ms 16116 KB Output is correct
2 Correct 296 ms 23660 KB Output is correct
3 Correct 286 ms 23116 KB Output is correct
4 Incorrect 228 ms 25676 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 16268 KB Output is correct
2 Incorrect 247 ms 15952 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 307 ms 19024 KB Output is correct
2 Correct 361 ms 28328 KB Output is correct
3 Correct 343 ms 27980 KB Output is correct
4 Incorrect 300 ms 31140 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 19024 KB Output is correct
2 Incorrect 310 ms 19024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 380 ms 22352 KB Output is correct
2 Correct 388 ms 33100 KB Output is correct
3 Correct 401 ms 32484 KB Output is correct
4 Incorrect 339 ms 35680 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 396 ms 22352 KB Output is correct
2 Incorrect 346 ms 22352 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 429 ms 25424 KB Output is correct
2 Correct 432 ms 37792 KB Output is correct
3 Correct 431 ms 36900 KB Output is correct
4 Incorrect 428 ms 41036 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 436 ms 25424 KB Output is correct
2 Incorrect 382 ms 25424 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 31568 KB Output is correct
2 Correct 586 ms 47180 KB Output is correct
3 Correct 553 ms 46248 KB Output is correct
4 Incorrect 489 ms 50764 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 587 ms 31568 KB Output is correct
2 Incorrect 511 ms 31568 KB Output isn't correct
3 Halted 0 ms 0 KB -