Submission #86932

# Submission time Handle Problem Language Result Execution time Memory
86932 2018-11-28T15:55:27 Z popovicirobert Mobile (BOI12_mobile) C++14
33 / 100
731 ms 132096 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const double eps = 1e-9;
const double INF = 1e18;
const int MAXN = (int) 1e6;

struct Point {
    double x, y;
}pts[MAXN + 1];

inline double dist(Point a, Point b) {
    return sqrt(1LL * (a.x - b.x) * (a.x - b.x) + 1LL * (a.y - b.y) * (a.y - b.y));
}

struct Data {
    double l, r;
    int id;
};

vector <Data> stk;

inline bool eq(double a, double b) {
    return fabs(a - b) < eps;
}

double L;

inline bool ok(double &l, double &r, Point b) {
    Point a = pts[stk.back().id];
    if(eq(a.x, b.x)) {
        return 0;
    }
    double x = 1.0 * (b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y) / (2 * (b.x - a.x));
    if(x > L) {
        return 0;
    }
    if(x - stk.back().l > 0) {
        stk.back().r = x;
        l = x;
        r = L;
        return 0;
    }
    l = stk.back().l;
    r = L;
    return 1;
}

int main() {
    //ifstream cin("B.in");
    //ofstream cout("B.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n >> L;
    for(i = 1; i <= n; i++) {
        cin >> pts[i].x >> pts[i].y;
    }
    stk.push_back({0, L, 1});
    for(i = 2; i <= n; i++) {
        double l = INF, r = -INF;
        while(!stk.empty()) {
            if(ok(l, r, pts[i])) {
                stk.pop_back();
            }
            else {
                break;
            }
        }
        if(r - l > 0) {
            stk.push_back({l, r, i});
        }
    }
    double ans = 0;
    for(auto it : stk) {
        ans = max(ans, dist(pts[it.id], {it.l, 0}));
        ans = max(ans, dist(pts[it.id], {it.r, 0}));
    }
    cout << fixed << setprecision(20) << ans;
    //cin.close();
    //cout.close();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 628 KB Output is correct
2 Correct 6 ms 780 KB Output is correct
3 Correct 8 ms 916 KB Output is correct
4 Correct 5 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1080 KB Output is correct
2 Correct 6 ms 1132 KB Output is correct
3 Correct 4 ms 1200 KB Output is correct
4 Correct 6 ms 1208 KB Output is correct
5 Incorrect 5 ms 1336 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3296 KB Output is correct
2 Correct 61 ms 4272 KB Output is correct
3 Correct 37 ms 4684 KB Output is correct
4 Correct 52 ms 6072 KB Output is correct
5 Incorrect 27 ms 6128 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 7264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 11268 KB Output is correct
2 Correct 76 ms 11268 KB Output is correct
3 Correct 58 ms 11820 KB Output is correct
4 Correct 80 ms 12284 KB Output is correct
5 Correct 50 ms 13124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 14900 KB Output is correct
2 Correct 68 ms 16240 KB Output is correct
3 Correct 62 ms 17620 KB Output is correct
4 Correct 76 ms 19320 KB Output is correct
5 Correct 65 ms 20520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 22900 KB Output is correct
2 Correct 77 ms 23440 KB Output is correct
3 Correct 56 ms 24824 KB Output is correct
4 Correct 76 ms 26404 KB Output is correct
5 Correct 65 ms 27748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 50672 KB Output is correct
2 Correct 344 ms 50672 KB Output is correct
3 Correct 329 ms 53356 KB Output is correct
4 Correct 384 ms 62832 KB Output is correct
5 Correct 309 ms 69688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 337 ms 77828 KB Output is correct
2 Correct 315 ms 85420 KB Output is correct
3 Correct 279 ms 91896 KB Output is correct
4 Correct 359 ms 99568 KB Output is correct
5 Correct 351 ms 106920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 392 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 409 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 415 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 499 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 513 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 555 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 586 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 731 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -