QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#518981 | #8775. MountainCraft | solar_express# | WA | 0ms | 3612kb | C++14 | 1.6kb | 2024-08-14 14:58:16 | 2024-08-14 14:58:17 |
Judging History
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'