답안 #1056953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056953 2024-08-13T12:40:16 Z TimAni Mobile (BOI12_mobile) C++17
50 / 100
1000 ms 23888 KB
// time-limit: 3000
 
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const double eps = 1e-6;
 
struct point {
    int x{}, y{};
};
 
void solve() {
    int n, L;
    cin >> n >> L;
    vector<point> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    auto intersection = [&](const point& A, double R) -> array<double, 2> {
        if(abs(A.y) > R) {
            return {L + 2, -2};
        }
        double D = 1.0 * R * R - 1.0 * A.y * A.y; // divided by 4
        double x1 = A.x - sqrt(D);
        double x2 = A.x + sqrt(D);
        if(x2 < x1) swap(x1, x2);
        if(x1 < 0) x1 = -1; 
        if(x2 > L) x2 = L + 1;
        if(x2 < 0 || x1 > L)
            return {L + 2, -2};
        return {x1, x2};
    };
 
    auto good = [&](double R) {
        vector<array<double, 2>> segs(n);
        for(int i = 0; i < n; i++) {
            segs[i] = intersection(p[i], R);
        }
        sort(segs.begin(), segs.end());
        double r = segs[0][1], l = segs[0][0];
        int i = 0;
        while(i + 1 < n && segs[i + 1][0] <= r) {
            r = max(segs[i + 1][1], r);
            i++;
        }
        return r >= L && l <= 0;
    };
 
    double l = 0, r = 4e9;
    while(r - l > eps) {
        double R = (r + l) / 2;
        if(good(R)) {
            r = R;
        }
        else {
            l = R;
        }
        
    }
    cout << fixed << setprecision(-log10(eps)) << r << endl;
}
 
int main() {
    cin.tie(0)->sync_with_stdio(0);
    double T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:23:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   23 |             return {L + 2, -2};
      |                     ~~^~~
mobile.cpp:32:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   32 |             return {L + 2, -2};
      |                     ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 520 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 568 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 9 ms 568 KB Output is correct
4 Correct 9 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 8 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 348 KB Output is correct
2 Correct 7 ms 568 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 8 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 2208 KB Output is correct
2 Correct 182 ms 2216 KB Output is correct
3 Correct 131 ms 1660 KB Output is correct
4 Correct 148 ms 2236 KB Output is correct
5 Correct 92 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 2196 KB Output is correct
2 Correct 137 ms 2060 KB Output is correct
3 Correct 177 ms 2388 KB Output is correct
4 Correct 155 ms 2308 KB Output is correct
5 Correct 171 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 2540 KB Output is correct
2 Correct 202 ms 2392 KB Output is correct
3 Correct 224 ms 2396 KB Output is correct
4 Correct 191 ms 2652 KB Output is correct
5 Correct 172 ms 2536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 2652 KB Output is correct
2 Correct 267 ms 2648 KB Output is correct
3 Correct 254 ms 2648 KB Output is correct
4 Correct 194 ms 2904 KB Output is correct
5 Correct 220 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 2648 KB Output is correct
2 Correct 262 ms 2652 KB Output is correct
3 Correct 276 ms 2652 KB Output is correct
4 Correct 228 ms 2788 KB Output is correct
5 Correct 193 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 12116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 12488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 14536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 14512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 16792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 16788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 19048 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 19064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1032 ms 23888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 23888 KB Time limit exceeded
2 Halted 0 ms 0 KB -