QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741931#8775. MountainCraftactorWA 4ms146072kbC++142.8kb2024-11-13 15:30:202024-11-13 15:30:30

Judging History

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

  • [2024-11-13 15:30:30]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:146072kb
  • [2024-11-13 15:30:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for (int i = (l); i <= (r); i++)
#define per(i,r,l) for (int i = (r); i >= (l); i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define maxn(a, b) a = max(a, b)
#define minn(a, b) a = min(a, b)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod = 998244353;
mt19937 gen(random_device{}());
ll rp(ll a,ll b) {ll res=1%mod;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int inf = 1e9;
const int N = 200010;

struct info {
    int mn, cnt, lz;
    info(): mn(0), cnt(0), lz(0){}
    friend info operator + (const info &x, const info &y) {
        info z;
        z.mn = min(x.mn, y.mn);
        z.cnt = 0;
        if (x.mn == z.mn) z.cnt += x.cnt;
        if (y.mn == z.mn) z.cnt += y.cnt;
        return z;
    }
};

int idx;
int ls[N*60], rs[N*60];
info s[N*60];

void getnew(int &x, int sz) {
    if (x) return ;
    x = ++idx;
    s[x].cnt = sz;
}

void pushdown(int id) {
    if (s[id].lz) {
        s[ls[id]].mn += s[id].lz;
        s[rs[id]].mn += s[id].lz;
        s[ls[id]].lz += s[id].lz;
        s[rs[id]].lz += s[id].lz;
        s[id].lz = 0;
    }
}

void change(int id, int l, int r, int x, int y, int c) {
    if (x <= l && r <= y) {
        s[id].lz += c;
        s[id].mn += c;
        return ;
    }
    int mid = (l + r) >> 1;
    getnew(ls[id], mid - l + 1);
    getnew(rs[id], r - mid);
    pushdown(id);
    if (x <= mid) change(ls[id], l, mid, x, y, c);
    if (y > mid) change(rs[id], mid + 1, r, x, y, c);
    s[id] = s[ls[id]] + s[rs[id]];
}

info query(int id, int l, int r, int x, int y) {
    if (x <= l && r <= y) {
        return s[id];
    }
    int mid = (l + r) >> 1;
    getnew(ls[id], mid - l + 1);
    getnew(rs[id], r - mid);
    pushdown(id);
    info res;
    if (x <= mid) res = res + query(ls[id], l, mid, x, y);
    if (y > mid) res = res + query(rs[id], mid + 1, r, x, y);
    return res;
}

int main() {
    int q, w;
    scanf("%d%d", &q, &w);
    set<PII> st;
    int rt = 0;
    getnew(rt, w);

    while (q--) {
        int x, y;
        scanf("%d%d", &x, &y);
        int l = x - y, r = x + y;
        maxn(l, 0);
        minn(r, w);
        if (st.count(mp(x, y))) {
            change(rt, 1, w, l + 1, r, -1);
            st.erase(mp(x, y));
        } else {
            // printf("%d %d +1\n", l, r);
            change(rt, 1, w, l + 1, r, 1);
            st.insert(mp(x, y));
        }
        // printf("%d %d %d %d\n", l, r, s[1].cnt, s[1].mn);
        printf("%.6lf\n", (w - s[1].cnt) * sqrt(2));
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 144600kb

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: 4ms
memory: 146072kb

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: -100
Wrong Answer
time: 4ms
memory: 146072kb

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
4.242641
12.727922
12.727922
11.313708
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
12.727922
11.313708
1...

result:

wrong answer 2nd numbers differ - expected: '14.1421356', found: '4.2426410', error = '0.7000000'