QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518976#8775. MountainCraftsolar_express#RE 0ms0kbC++141.6kb2024-08-14 14:56:032024-08-14 14:56:03

Judging History

你现在查看的是最新测评结果

  • [2024-08-14 14:56:03]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-08-14 14:56:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

set<pair<int, int> > S;
const int N = 2e5+5;
struct info {
    int lc, rc;
    int v, cnt, tag;
} a[N<<6];
int tot;

void gen(int &u, int l, int r) {
if (!u) {
        u = ++tot;
        a[u].cnt = r - l;
    }
}

int rt;
void ch(int &u, int l, int r, int s, int t, int v) {
    gen(u, l, r);
    if (l == s && r == t) {
        a[u].v += v;
        a[u].tag += v;
        return;
    }
    int mid = (l + r) >> 1;
    gen(a[u].lc, l, mid);
    gen(a[u].rc, mid, r);
    a[a[u].lc].v += a[u].tag;
    a[a[u].rc].v += a[u].tag;
    a[a[u].lc].tag += a[u].tag;
    a[a[u].rc].tag += a[u].tag;
    a[u].tag = 0;
    if (t < mid) ch(a[u].lc, l, mid, s, t, v);
    else if (s >= mid) ch(a[u].rc, mid, r, s, t, v);
    else {
        ch(a[u].lc, l, mid, s, mid, v);
        ch(a[u].rc, mid, r, mid, t, v);
    }
    int lc = a[u].lc, rc = a[u].rc;
    a[u].v = min(a[lc].v, a[rc].v);
    a[u].cnt = 0;
    if (a[lc].v == a[u].v) a[u].cnt += a[lc].cnt;
    if (a[rc].v == a[u].v) a[u].cnt += a[rc].cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, R;
    cin >> n >> R;
    while (n--) {
        int x, y;
        cin >> x >> y;
        int l = max(0, x-y), r = min(R, x+y);
        if (S.find({x, y}) != end(S)) {
            ch(rt, 0, R, l, r, -1);
            S.erase({x, y});
        } else {
            ch(rt, 0, R, l, r, 1);
            S.insert({x, y});
        }
        cout << setprecision(20) << (R - a[rt].cnt) * sqrt(2) << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 10
3 2
7 3
9 6

output:


result: