답안 #1102819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102819 2024-10-19T03:42:46 Z Zero_OP Mobile (BOI12_mobile) C++14
100 / 100
558 ms 35404 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 = 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-3;
 
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 = sqrt(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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 2 ms 544 KB Output is correct
3 Correct 3 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1616 KB Output is correct
2 Correct 32 ms 1616 KB Output is correct
3 Correct 20 ms 1272 KB Output is correct
4 Correct 35 ms 1616 KB Output is correct
5 Correct 19 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1788 KB Output is correct
2 Correct 29 ms 1360 KB Output is correct
3 Correct 36 ms 1784 KB Output is correct
4 Correct 83 ms 1616 KB Output is correct
5 Correct 40 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1616 KB Output is correct
2 Correct 36 ms 1616 KB Output is correct
3 Correct 32 ms 1788 KB Output is correct
4 Correct 53 ms 1872 KB Output is correct
5 Correct 50 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1872 KB Output is correct
2 Correct 38 ms 1872 KB Output is correct
3 Correct 40 ms 1872 KB Output is correct
4 Correct 58 ms 1872 KB Output is correct
5 Correct 46 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 2040 KB Output is correct
2 Correct 45 ms 1872 KB Output is correct
3 Correct 45 ms 1872 KB Output is correct
4 Correct 54 ms 1872 KB Output is correct
5 Correct 48 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 8440 KB Output is correct
2 Correct 194 ms 8272 KB Output is correct
3 Correct 179 ms 8272 KB Output is correct
4 Correct 233 ms 8272 KB Output is correct
5 Correct 237 ms 8440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 8272 KB Output is correct
2 Correct 240 ms 8272 KB Output is correct
3 Correct 174 ms 8272 KB Output is correct
4 Correct 237 ms 8272 KB Output is correct
5 Correct 224 ms 8272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 200 ms 9808 KB Output is correct
2 Correct 245 ms 9808 KB Output is correct
3 Correct 253 ms 9808 KB Output is correct
4 Correct 317 ms 9808 KB Output is correct
5 Correct 275 ms 9808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 9808 KB Output is correct
2 Correct 312 ms 9808 KB Output is correct
3 Correct 223 ms 9808 KB Output is correct
4 Correct 298 ms 9808 KB Output is correct
5 Correct 286 ms 9808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 11344 KB Output is correct
2 Correct 273 ms 11344 KB Output is correct
3 Correct 276 ms 11512 KB Output is correct
4 Correct 359 ms 11344 KB Output is correct
5 Correct 319 ms 11512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 11344 KB Output is correct
2 Correct 343 ms 11344 KB Output is correct
3 Correct 259 ms 11344 KB Output is correct
4 Correct 330 ms 11512 KB Output is correct
5 Correct 315 ms 11344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 262 ms 12880 KB Output is correct
2 Correct 313 ms 12880 KB Output is correct
3 Correct 286 ms 12880 KB Output is correct
4 Correct 372 ms 12880 KB Output is correct
5 Correct 343 ms 24112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 12880 KB Output is correct
2 Correct 374 ms 12880 KB Output is correct
3 Correct 283 ms 12880 KB Output is correct
4 Correct 387 ms 13048 KB Output is correct
5 Correct 361 ms 24396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 345 ms 15952 KB Output is correct
2 Correct 392 ms 15952 KB Output is correct
3 Correct 368 ms 15952 KB Output is correct
4 Correct 490 ms 15952 KB Output is correct
5 Correct 491 ms 29516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 398 ms 15952 KB Output is correct
2 Correct 488 ms 15952 KB Output is correct
3 Correct 375 ms 28396 KB Output is correct
4 Correct 558 ms 35404 KB Output is correct
5 Correct 520 ms 30796 KB Output is correct