QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518981#8775. MountainCraftsolar_express#WA 0ms3612kbC++141.6kb2024-08-14 14:58:162024-08-14 14:58:17

Judging History

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

  • [2024-08-14 14:58:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-08-14 14:58:16]
  • 提交

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;
    if (!lc) return;
    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) << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

input:

3 10
3 2
7 3
9 6

output:

4
9
9

result:

wrong answer 1st numbers differ - expected: '5.6568540', found: '4.0000000', error = '0.2928932'