QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662264#9242. An Easy Geometry ProblemMo_Han136WA 17ms45000kbC++203.4kb2024-10-20 22:24:422024-10-20 22:24:43

Judging History

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

  • [2024-10-20 22:24:43]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:45000kb
  • [2024-10-20 22:24:42]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=head[a];i;i=e[i].nxt)
using namespace std;
const int M=2e5+5;

int n,m,k,b,a[M];
const int N=2;
const LL P[]={998244353,(LL)1e9+7};
struct node{
    LL h[N];
    node (){memset(h,0,sizeof(h));}
    void calc(LL x){
        rep(i,0,N-1)h[i]=x;
    }
    node operator + (const LL &_)const{
        node r;
        rep(i,0,N-1)r.h[i]=(h[i]+_)%P[i];
        return r;
    }
    node operator + (const node &_)const{
        node r;
        rep(i,0,N-1)r.h[i]=(h[i]+_.h[i])%P[i];
        return r;
    }
    node operator * (const LL &_)const{
        node r;
        rep(i,0,N-1)r.h[i]=h[i]*_%P[i];
        return r;
    }
    node operator * (const node &_)const{
        node r;
        rep(i,0,N-1)r.h[i]=h[i]*_.h[i]%P[i];
        return r;
    }
    bool operator == (const node &_)const{
        rep(i,0,N-1)if(h[i]^_.h[i])return 0;
        return 1;
    }
}T[M],E[M],B;
void init(){
    B.h[0]=2e8+3;
    B.h[1]=2e8+7;
    int n=2e5;
    T[0].calc(1);
    rep(i,1,n)T[i]=T[i-1]*B;
    rep(i,1,n)E[i]=E[i-1]+T[i-1];
}
#define lp p<<1
#define rp p<<1|1
struct Seg{
    int len[M<<2];
    node t[M<<2];
    LL c[M<<2];
    void up(int w,int p){
        if(w)t[p]=t[lp]+t[rp]*T[len[lp]];
        else t[p]=t[lp]*T[len[rp]]+t[rp];
    }
    void down(int p){
        if(!c[p])return;
        t[lp]=t[lp]+E[len[lp]]*c[p];c[lp]+=c[p];
        t[rp]=t[rp]+E[len[rp]]*c[p];c[rp]+=c[p];
        c[p]=0;
    }
    void build(int w,int l=1,int r=n,int p=1){
        len[p]=r-l+1;
        if(l==r){
            if(w)t[p].calc(2*a[l]-k*l);
            else t[p].calc(2*a[l]-k*l+2*b);
            return;
        }
        int mid=(l+r)>>1;
        build(w,l,mid,lp);
        build(w,mid+1,r,rp);
        up(w,p);
    }
    void chg(int x,int y,int z,int w,int l=1,int r=n,int p=1){
        if(l==x && r==y){
            t[p]=t[p]+E[len[p]]*z;c[p]+=z;
            return;
        }
        int mid=(l+r)>>1;down(p);
        if(y<=mid)chg(x,y,z,w,l,mid,lp);
        else if(mid<x)chg(x,y,z,w,mid+1,r,rp);
        else chg(x,mid,z,w,l,mid,lp),chg(mid+1,y,z,w,mid+1,r,rp);
        up(w,p);
    }
    node qry(int x,int y,int w,int l=1,int r=n,int p=1){
        if(l==x && r==y)return t[p];
        int mid=(l+r)>>1;down(p);
        if(y<=mid)return qry(x,y,w,l,mid,lp);
        if(mid<x)return qry(x,y,w,mid+1,r,rp);
        if(w)return qry(x,mid,w,l,mid,lp)+qry(mid+1,y,w,mid+1,r,rp)*T[mid-x+1];
        else return qry(x,mid,w,l,mid,lp)*T[y-mid]+qry(mid+1,y,w,mid+1,r,rp);
    }
}T1,T0;

bool chk(int x,int r){
    return T1.qry(x+1,x+r,1)==T0.qry(x-r,x-1,0);
}
int main(){
    init();
    scanf("%d%d%d%d",&n,&m,&k,&b);
    rep(i,1,n)scanf("%d",&a[i]);
    T1.build(1);
    T0.build(0);
    rep(i,1,m){
        int op,x,y,z;
        scanf("%d",&op);
        if(op==1){
            scanf("%d%d%d",&x,&y,&z);z<<=1;
            T1.chg(x,y,z,1);
            T0.chg(x,y,z,0);
        }
        if(op==2){
            scanf("%d",&x);
            int l=1,r=min(n-x,x-1);
            while(l<=r){
                int mid=(l+r)>>1;
                if(chk(x,mid))l=mid+1;
                else r=mid-1;
            }
            printf("%d\n",r);
        }
    }
    return 0;
}
/*
3
0 1 2
1 2 3
2 3 4

*/

详细

Test #1:

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

input:

6 6 6 2
1 5 9 10 15 18
2 2
1 3 3 -3
2 2
1 3 4 3
2 3
2 4

output:

1
0
2
0

result:

ok 4 number(s): "1 0 2 0"

Test #2:

score: 0
Accepted
time: 17ms
memory: 41340kb

input:

5000 5000 2 0
-329 -328 -327 -326 -325 -324 -323 -322 -321 -320 -319 -318 -317 -316 -315 -314 -313 -312 -311 -310 -309 -308 -307 -306 -305 -304 -303 -302 -301 -300 -299 -298 -297 -296 -295 -294 -293 -292 -291 -290 -289 -288 -287 -286 -285 -284 -283 -282 -281 -280 -279 -278 -277 -276 -275 -274 -273 -...

output:

2
304
73
29
61
292
139
48
17
99
6
5
53
93
3
91
65
29
33
306
21
24
17
21
281
12
16
1
33
7
18
96
7
40
39
13
7
46
43
16
1
72
33
16
22
5
6
189
27
1
35
107
43
34
3
27
20
21
44
56
96
36
2
27
22
30
32
6
5
105
27
37
12
58
2
21
154
17
110
57
3
7
33
15
24
94
68
25
1
14
10
4
10
2
25
39
36
33
164
11
19
181
11
3...

result:

ok 3337 numbers

Test #3:

score: -100
Wrong Answer
time: 12ms
memory: 45000kb

input:

5000 5000 2 0
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 86...

output:

362
82
14
234
140
5
44
136
22
43
29
96
59
23
25
61
193
22
39
39
23
53
48
76
100
58
120
24
12
106
32
48
73
63
116
16
136
10
28
15
84
30
65
1
54
15
16
70
1
95
74
14
17
20
36
254
22
29
70
172
106
2
25
8
98
35
169
16
2
2
99
10
36
40
3
69
272
170
219
12
79
26
78
100
10
167
140
70
34
17
23
21
55
10
6
17
6...

result:

wrong answer 2125th numbers differ - expected: '5', found: '4'