QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770837#8775. MountainCraftocharin#WA 11ms159312kbC++202.7kb2024-11-22 00:42:012024-11-22 00:42:01

Judging History

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

  • [2024-11-22 00:42:01]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:159312kb
  • [2024-11-22 00:42:01]
  • 提交

answer

/*

                                _/                                      _/
       _/_/        _/_/_/      _/_/_/        _/_/_/      _/  _/_/               _/_/_/
    _/    _/    _/            _/    _/    _/    _/      _/_/          _/       _/    _/
   _/    _/    _/            _/    _/    _/    _/      _/            _/       _/    _/
    _/_/        _/_/_/      _/    _/      _/_/_/      _/            _/       _/    _/

*/
#include<bits/stdc++.h>
#define int long long

using namespace std;
const double s2=sqrtl(2);
const int N=1e6+8;
int cnt=1;
struct tree{
    int l,r,mi,sum,tag;
    tree():l(0),r(0),mi(0),sum(0),tag(0){};
};
vector<tree>s(N<<2);
struct SegmentTree{
    void pushtag(int &u,int cl,int cr,int k){
        if(!u){
            u=++cnt;
            s[u].sum=cr-cl+1;
        }
        s[u].mi+=k;
        s[u].tag+=k;
    }
    void pushdown(int u,int cl,int cr){
        int mid=cl+cr>>1;
        pushtag(s[u].l,cl,mid,s[u].tag);
        pushtag(s[u].r,mid+1,cr,s[u].tag);
        s[u].tag=0;
    }
    void pushup(int u,int cl,int cr){
        s[u].mi=min(s[s[u].l].mi,s[s[u].r].mi);
        s[u].sum=0;
        int mid=cl+cr>>1;
        if(s[u].l){
            if(s[s[u].l].mi==s[u].mi) s[u].sum+=s[s[u].l].sum;
        }
        else s[u].sum+=mid-cl+1;
        if(s[u].r){
            if(s[s[u].r].mi==s[u].mi) s[u].sum+=s[s[u].r].sum;
        }
        else s[u].sum+=cr-mid;
    }
    int modify(int u,int cl,int cr,int l,int r,int k){
        if(!u) u=++cnt,s[u].sum=cr-cl+1;
        if(l<=cl && cr<=r){
            pushtag(u,cl,cr,k);
            return u;
        }
        pushdown(u,cl,cr);
        int mid=cl+cr>>1;
        if(l<=mid) s[u].l=modify(s[u].l,cl,mid,l,r,k);
        if(mid<r) s[u].r=modify(s[u].r,mid+1,cr,l,r,k);
        pushup(u,cl,cr);
        return u;
    }
    int query(int u,int cl,int cr){
        return cr-cl+1-s[1].sum;
    }
}seg;

void dfs(int u,int cl,int cr){
    if(!u) return;
    cerr<<u<<" "<<cl<<" "<<cr<<" : "<<s[u].mi<<" "<<s[u].sum<<endl;
    int mid=cl+cr>>1;
    dfs(s[u].l,cl,mid);
    dfs(s[u].r,mid+1,cr);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    map<array<int,2>,int>mp;
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        if(mp[{x,y}]){
            mp[{x,y}]=0;
            seg.modify(1,1,q,max(1ll,x-y+1),min(q,x+y),-1);
        }
        else{
            mp[{x,y}]=1;
            seg.modify(1,1,q,max(1ll,x-y+1),min(q,x+y),1);
        }
        // dfs(1,1,q);
        // cerr<<endl;
        cout<<fixed<<setprecision(15)<<seg.query(1,1,q)*s2<<"\n";
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 159212kb

input:

3 10
3 2
7 3
9 6

output:

5.656854249492381
12.727922061357857
12.727922061357857

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 7ms
memory: 159312kb

input:

5 100
31 41
59 26
31 41
59 26
31 41

output:

101.823376490862856
120.208152801713084
73.539105243400954
0.000000000000000
101.823376490862856

result:

ok 5 numbers

Test #3:

score: -100
Wrong Answer
time: 8ms
memory: 159276kb

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.313708498984761
4.242640687119286
12.727922061357857
12.727922061357857
11.313708498984761
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.727922061357857
12.7279220613578...

result:

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