QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748248 | #8775. MountainCraft | cyj888 | WA | 6ms | 38856kb | C++14 | 2.1kb | 2024-11-14 19:49:25 | 2024-11-14 19:49:30 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define ott(i, l, r) for (register int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (register int i = (r); i >= (l); i --)
using namespace std;
typedef long long ll;
typedef long double ld;
int read () {
int x = 0; bool f = false; char c = getchar ();
while (!isdigit (c)) f |= (c == '-'), c = getchar ();
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return f ? -x : x;
}
const int N = 2e5 + 110, mod = 1e9 + 7;
int n, m, q, w, res;
pair <int, int> a[N];
map <int, map <int, bool> > del;
int ta[N << 1], ts[N << 1];
struct Segment_Tree {
pair <int, int> to[N << 2];
set <int> lv[N]; bool rev;
#define ls p << 1
#define rs p << 1 | 1
void pup (int p) {
return void (to[p] = to[rs].fi ? to[rs] : to[ls]);
}
void add (int p, int l, int r, int x, int v) {
if (l >= r) {
if (v < 0) lv[l].erase (-v); else lv[l].insert (v); to[p].se = l;
return void (to[p].fi = lv[l].empty () ? 0 : (rev ? *lv[l].rbegin () : *lv[l].begin ()));
}
int mid = l + r >> 1;
x <= mid ? add (ls, l, mid, x, v) : add (rs, mid + 1, r, x, v);
return pup (p);
}
} Ta, Ts;//R L
int main () {
q = read (), w = read (), Ta.rev = false, Ts.rev = true;
ott (i, 1, q) {
int x = read (), y = read (); a[i].fi = x, a[i].se = y;
ta[++ ta[0]] = y + x, ts[++ ts[0]] = y - x;
}
sort (ta + 1, ta + 1 + ta[0]), sort (ts + 1, ts + 1 + ts[0]);
ott (i, 1, q) {
int x = a[i].fi, y = a[i].se;
int xa = lower_bound (ta + 1, ta + 1 + ta[0], y + x) - ta;
int xs = lower_bound (ts + 1, ts + 1 + ts[0], y - x) - ts;
if (del[x][y]) Ta.add (1, 1, ta[0], xa, -x), Ts.add (1, 1, ts[0], xs, -x);
else Ta.add (1, 1, ta[0], xa, x), Ts.add (1, 1, ts[0], xs, x);
del[x][y] ^= 1; pair <int, int> l = Ts.to[1], r = Ta.to[1];
// printf ("[%d %d]\n", l.fi, r.fi);
if (l.fi) {
assert (l.fi <= r.fi);
res = r.fi - l.fi + min (l.fi, ts[l.se] + l.fi) + min (w - r.fi, ta[r.se] - r.fi);
}
//min (p[1].x, p[1].y)
printf ("%.6lf\n", 1.0 * res * pow (2, 0.5)), res = 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 37772kb
input:
3 10 3 2 7 3 9 6
output:
5.656854 12.727922 12.727922
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 3ms
memory: 37160kb
input:
5 100 31 41 59 26 31 41 59 26 31 41
output:
101.823376 120.208153 73.539105 0.000000 101.823376
result:
ok 5 numbers
Test #3:
score: 0
Accepted
time: 6ms
memory: 37372kb
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.313708 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 14.142136 ...
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 38856kb
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.384776 76.367532 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.421356 141.4...
result:
wrong answer 2nd numbers differ - expected: '41.0121933', found: '76.3675320', error = '0.8620690'