QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#652487 | #8775. MountainCraft | yzkkai# | WA | 0ms | 3868kb | C++20 | 2.0kb | 2024-10-18 18:46:26 | 2024-10-18 18:46:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using LL = long long;
using pii = pair<int, int>;
#define sz(x) (signed)size(x)
struct segTree {
int l, r, mid;
int mn = 0, cnt = 0, tag = 0;
segTree *lson = nullptr, *rson = nullptr;
segTree (int _l, int _r) : l(_l), r(_r), mid((l + r) >> 1), cnt(r - l) {}
void push() {
for (segTree* son : {lson, rson}) {
son->mn += tag;
son->tag += tag;
}
tag = 0;
}
void pull() {
mn = min(lson->mn, rson->mn);
if (lson->mn < rson->mn)
cnt = lson->cnt;
else if (lson->mn > rson->mn)
cnt = rson->cnt;
else
cnt = lson->cnt + rson->cnt;
}
void add(int ql, int qr, int val) {
if (l == ql && r == qr) {
mn += val;
tag = val;
return;
}
if (lson == nullptr)
lson = new segTree(l, mid);
if (rson == nullptr)
rson = new segTree(mid, r);
push();
if (qr <= mid) {
lson->add(ql, qr, val);
}
else if (mid <= ql) {
rson->add(ql, qr, val);
}
else {
lson->add(ql, mid, val);
rson->add(mid, qr, val);
}
pull();
}
};
void solve () {
int q, w;
cin >> q >> w;
set<pii> st;
segTree* root = new segTree(0, w);
while (q--) {
int x, y;
cin >> x >> y;
int l = max(0, x - y), r = min(w, x + y);
if (st.count({x, y})) {
root->add(l, r, -1);
st.erase({x, y});
}
else {
root->add(l, r, 1);
st.emplace(x, y);
}
int tmp = w;
if (root->mn == 0)
tmp -= root->cnt;
cout << fixed << setprecision(10) << sqrtl(2) * tmp << '\n';
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
3 10 3 2 7 3 9 6
output:
5.6568542495 12.7279220614 12.7279220614
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
5 100 31 41 59 26 31 41 59 26 31 41
output:
101.8233764909 120.2081528017 73.5391052434 0.0000000000 101.8233764909
result:
ok 5 numbers
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
100 10 6 4 2 3 7 6 5 5 3 6 7 5 5 8 10 4 9 8 0 9 9 10 9 3 2 3 10 10 8 4 10 9 0 1 1 7 0 2 3 4 10 3 3 10 7 4 7 5 1 4 0 7 1 9 5 6 8 8 7 4 8 1 3 9 2 1 5 5 2 1 10 9 8 4 0 9 10 7 4 1 9 10 8 6 5 4 1 4 0 9 9 3 4 8 5 10 7 2 8 10 7 10 3 4 2 2 8 5 0 9 5 3 1 4 6 4 0 3 8 1 1 6 3 8 8 4 6 5 10 2 2 2 8 4 6 1 2 4 6 4...
output:
11.3137084990 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.142...
result:
wrong answer 40th numbers differ - expected: '14.1421356', found: '11.3137085', error = '0.2000000'