QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544374#8775. MountainCraftucup-team093#WA 7ms159740kbC++201.4kb2024-09-02 15:51:142024-09-02 15:51:14

Judging History

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

  • [2024-09-02 15:51:14]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:159740kb
  • [2024-09-02 15:51:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 10;
const double r2 = sqrt(2);
using peak = pair<int, int>;

struct node{
    peak l, r;
    double ans;
} tr[N * 33];

int sons[N * 33][2], tcnt = 1;

map<int, set<int> > mp;

node merge(const node &l, const node &r) {
    if(l.l.second == 0) return r;
    if(r.l.second == 0) return l;
    if(r.l.second - r.l.first >= l.l.second - l.l.first) return r;
    if(l.r.first + l.r.second >= r.r.first + r.r.second) return l;
    return node{l.l, r.r, l.ans + r.ans + r2 * abs(l.r.first - r.l.first)};
}

void modify(int u, int p, int x, int lvl) {
    if(lvl == -1) {
        tr[u].l = tr[u].r = x ? peak{p, x} : peak{0, 0};
        tr[u].ans = 0;
        return;
    }
    int v = (p >> lvl) & 1;
    if(!sons[u][v]) sons[u][v] = ++tcnt;
    modify(sons[u][v], p, x, lvl - 1);
    tr[u] = merge(tr[sons[u][0]], tr[sons[u][1]]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int q, w;
    cin >> q >> w;

    cout << fixed << setprecision(7);

    for(int i = 1, x, y; i <= q; i ++) {
        cin >> x >> y;
        if(mp[x].count(y)) mp[x].erase(y);
        else mp[x].insert(y);
        modify(1, x, mp[x].size() ? *mp[x].rbegin() : 0, 29);
        cout << (tr[1].l.second ? tr[1].ans + (min(tr[1].l.first, tr[1].l.second) + min(w - tr[1].r.first, tr[1].r.second)) * r2 : 0.0) << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 159064kb

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: 158568kb

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

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

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
76.3675324
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: '76.3675324', error = '0.8620690'