답안 #142993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142993 2019-08-12T14:20:53 Z popovicirobert Balloons (CEOI11_bal) C++14
20 / 100
176 ms 65540 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



/*const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

const double eps = 1e-4;
const int MAXN = (int) 2e5;

double cx[MAXN + 1], cy[MAXN + 1];

inline bool inter(double xa, double ya, double xb, double yb) {
    return (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb) < (ya + yb) * (ya + yb);
}

struct SegTree {
    struct Data {
        int pos;
        bool operator <(const Data &other) const {
            return cx[pos] + cy[pos] - cx[other.pos] - cy[other.pos] >= 0;

        }
    };

    struct Node {
        int st, dr;
        set <Data> mst;
        Node() {
            st = dr = -1;
        }
    };

    vector <Node> aint;

    inline void init() {
        aint.resize(1);
    }

    inline void fix(int &x) {
        if(x == -1) {
            x = aint.size();
            aint.push_back(Node());
        }
    }

    void update(int nod, double left, double right, int pos) {
        if(right - left < eps) { return ; }

        aint[nod].mst.insert({pos});
        fix(aint[nod].st);
        fix(aint[nod].dr);

        double mid = (left + right) * 0.5;
        if(mid - (cx[pos] - cy[pos]) >= 0) update(aint[nod].st, left, mid, pos);
        else update(aint[nod].dr, mid, right, pos);
    }

    bool query(int nod, double left, double right, double x, double y) {
        if(right - left < eps) return 0;

        if(x - y - right >= 0) {
            auto it = aint[nod].mst.begin();
            while(it != aint[nod].mst.end() && cx[it -> pos] + cy[it -> pos] >= x - y) {
                if(inter(x, y, cx[it -> pos], cy[it -> pos])) {
                    return 1;
                }
                it = next(it);
            }
            return 0;
        }

        fix(aint[nod].st);
        fix(aint[nod].dr);

        double mid = (left + right) * 0.5;
        bool ans = 0;
        ans |= query(aint[nod].st, left, mid, x, y);
        if(x - y - mid > 0) ans |= query(aint[nod].dr, mid, right, x, y);

        return ans;
    }
};


int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    SegTree st; st.init();
    for(i = 1; i <= n; i++) {
        double r;
        cin >> cx[i] >> r;

        cx[i] += 1e9;

        double l = 0;
        while(r - l > eps) {
            double mid = (l + r) * 0.5;
            cy[i] = mid;
            if(st.query(0, 0, 2e9, cx[i], cy[i]) == 0) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        cy[i] = (l + r) * 0.5;
        st.update(0, 0, 2e9, i);
        cout << fixed << setprecision(3) << cy[i] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 680 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 15588 KB 15th numbers differ - expected: '0.8630000000', found: '8957.0000000000', error = '8956.1370000000'
# 결과 실행 시간 메모리 Grader output
1 Incorrect 169 ms 60208 KB 14th numbers differ - expected: '108.0020000000', found: '762.0000000000', error = '653.9980000000'
# 결과 실행 시간 메모리 Grader output
1 Runtime error 176 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 161 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 165 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 163 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 170 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 173 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -