QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#526450 | #8775. MountainCraft | megumi# | WA | 1ms | 3944kb | C++14 | 2.6kb | 2024-08-21 16:08:00 | 2024-08-21 16:08:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9')
f = (c == '-') ? -1 : 1, c = getchar();
while (c >= '0' && c <= '9')
x = x * 10 + c - 48, c = getchar();
return f * x;
}
struct node {
int v, min, lazy;
} a[1000010];
void pushup(int k) {
if (a[k << 1].min == a[k << 1 | 1].min)
a[k].min = a[k << 1].min, a[k].v = a[k << 1 | 1].v + a[k << 1].v;
if (a[k << 1].min < a[k << 1 | 1].min)
a[k].min = a[k << 1].min, a[k].v = a[k << 1].v;
if (a[k << 1].min > a[k << 1 | 1].min)
a[k].min = a[k << 1 | 1].min, a[k].v = a[k << 1 | 1].v;
}
void build(int k, int l, int r) {
if (l == r) {
a[k].lazy = 0, a[k].v = 1, a[k].min = 0;
return;
}
int mid = (l + r) >> 1;
build(k << 1, l, mid);
build(k << 1 | 1, mid + 1, r);
pushup(k);
}
void pushdown(int k) {
if (!a[k].lazy)
return;
a[k << 1].min += a[k].lazy;
a[k << 1 | 1].min += a[k].lazy;
a[k << 1].lazy += a[k].lazy;
a[k << 1 | 1].lazy += a[k].lazy;
a[k].lazy = 0;
}
void update(int k, int l, int r, int begin, int end, int v) {
if (l > end || r < begin)
return;
if (l >= begin && r <= end) {
a[k].min += v;
a[k].lazy += v;
return;
}
pushdown(k);
int mid = (l + r) >> 1;
update(k << 1, l, mid, begin, end, v);
update(k << 1 | 1, mid + 1, r, begin, end, v);
pushup(k);
}
int find(int k, int l, int r, int begin, int end) {
if (l > end || r < begin)
return 0;
if (l >= begin && r <= end) {
if (a[k].min == 0)
return a[k].v;
else
return 0;
}
pushdown(k);
int mid = (l + r) >> 1;
if (end <= mid)
return find(k << 1, l, mid, begin, end);
else if (begin > mid)
return find(k << 1 | 1, mid + 1, r, begin, end);
else
return find(k << 1, l, mid, begin, mid) +
find(k << 1 | 1, mid + 1, r, mid + 1, end);
}
map<pair<int, int>, int> f;
signed main() {
int q = read(), w = read();
build(1, 1, w + 1);
while (q--) {
int x = read(), y = read();
int l = max(x - y, 0) + 1, r = min(w, x + y) + 1;
f[{x, y}]++;
int p = f[{x, y}];
if (p % 2 == 1)
update(1, 1, w + 1, l, r, 1);
else
update(1, 1, w + 1, l, r, -1);
int P = find(1, 1, w + 1, 1, w + 1);
P = w + 1 - P;
if (P == 0)
P = 1;
printf("%.7lf\n", sqrt(2) * (P - 1));
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3944kb
input:
3 10 3 2 7 3 9 6
output:
5.6568542 12.7279221 12.7279221
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
5 100 31 41 59 26 31 41 59 26 31 41
output:
101.8233765 120.2081528 73.5391052 0.0000000 101.8233765
result:
ok 5 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3888kb
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.3137085 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14.1421356 14....
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3880kb
input:
1000 100 95 8 54 8 64 96 47 34 77 47 99 91 45 70 8 6 64 84 48 42 53 14 73 66 38 27 6 52 19 75 33 39 6 24 37 80 27 45 96 48 55 95 67 1 23 78 40 4 76 7 77 22 4 47 41 31 60 54 96 37 79 52 63 40 7 92 17 7 74 12 93 16 87 5 67 43 60 29 71 58 52 41 53 84 38 2 46 87 13 54 54 14 16 93 57 7 91 98 31 23 70 3 9...
output:
18.3847763 42.4264069 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 141.4213562 14...
result:
wrong answer 2nd numbers differ - expected: '41.0121933', found: '42.4264069', error = '0.0344828'