Submission #1063921

# Submission time Handle Problem Language Result Execution time Memory
1063921 2024-08-18T06:08:08 Z daviedu Mobile (BOI12_mobile) C++17
32 / 100
214 ms 19540 KB
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ld long double

struct P{
    ll x, y;
};

void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }

ld border(ld x, ld y, ld a, ld b){
    return (a*a + b*b - x*x - y*y) / (2*a - 2*x);
}

ld dist(ld x, ld y, ld point){
    return sqrtl(y*y + (point-x)*(point-x));
}

signed main(){
    fastio;
    int n, r;
    cin >> n >> r;
    stack<pair<int, int>> st;
    int a, b, x, y;
    for (int i=0; i<n; i++){
        cin >> a >> b;
        if (b < 0) b = -b;
        
        while (!st.empty() && st.top().first == a && st.top().second > b) st.pop();

        while ((int)st.size() > 1){
            tie(x, y) = st.top();
            st.pop();

            // if prev is not a useless point, put it back and stop
            if (border(x, y, a, b) > border(st.top().first, st.top().second, x, y)){
                st.push({x, y});
                break;
            }
        }

        st.push({a, b});
    }
    ld ans=0;
    ld right=r;
    while ((int)st.size() > 1){
        tie(a, b) = st.top();
        st.pop();
        tie(x, y) = st.top();
        ld left = border(x, y, a, b);
        if (left >= right) continue;
        if (right >= 0 && right <= r) ans = max(ans, dist(a, b, right));
        if (left >= 0 && left <= r) ans = max(ans, dist(a, b, left));
        right = left;
    }
    tie(a, b) = st.top();
    if (right >= 0) {
        ans = max(ans, dist(a, b, right));
        ans = max(ans, dist(a, b, 0));
    }
    cout << fixed << setprecision(13);
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1112 KB Output is correct
2 Incorrect 11 ms 1464 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1116 KB Output is correct
2 Correct 11 ms 1116 KB Output is correct
3 Correct 13 ms 1368 KB Output is correct
4 Correct 14 ms 1628 KB Output is correct
5 Correct 15 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1748 KB Output is correct
2 Incorrect 12 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2244 KB Output is correct
2 Incorrect 16 ms 1632 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 8632 KB Output is correct
2 Correct 99 ms 7964 KB Output is correct
3 Correct 73 ms 7512 KB Output is correct
4 Correct 93 ms 9808 KB Output is correct
5 Correct 84 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 9044 KB Output is correct
2 Correct 74 ms 7468 KB Output is correct
3 Correct 67 ms 6736 KB Output is correct
4 Correct 93 ms 9556 KB Output is correct
5 Correct 83 ms 7504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 10324 KB Output is correct
2 Incorrect 87 ms 9628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 10064 KB Output is correct
2 Correct 92 ms 8792 KB Output is correct
3 Incorrect 91 ms 7632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 92 ms 12112 KB Output is correct
2 Incorrect 102 ms 11204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11820 KB Output is correct
2 Correct 118 ms 9936 KB Output is correct
3 Incorrect 102 ms 9776 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 13860 KB Output is correct
2 Incorrect 121 ms 12624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 13392 KB Output is correct
2 Correct 142 ms 11492 KB Output is correct
3 Incorrect 109 ms 10840 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 138 ms 17120 KB Output is correct
2 Incorrect 144 ms 15776 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 16724 KB Output is correct
2 Correct 147 ms 14152 KB Output is correct
3 Correct 142 ms 13904 KB Output is correct
4 Correct 214 ms 19540 KB Output is correct
5 Correct 171 ms 14932 KB Output is correct