QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#782104 | #9242. An Easy Geometry Problem | lichenyu_ac | WA | 11ms | 11984kb | C++14 | 2.0kb | 2024-11-25 18:55:18 | 2024-11-25 18:55:19 |
Judging History
answer
#include<bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;
const int N=2e5+10;
const ull base=10007;
ull n,q,b,k;
ull pw[N],a[N];
#define lc (p<<1)
#define rc (p<<1|1)
#define mid ((L+R)>>1)
ull dat[2][N<<2];
ull len[N<<2];
void upd(int p){
dat[0][p]=dat[0][lc]+dat[1][rc]*len[lc];
dat[1][p]=dat[1][lc]*len[rc]+dat[1][rc];
}
void build(int p,int L,int R){
len[p]=R-L+1;
if(L==R)dat[0][p]=dat[1][p]=a[L];
else build(lc,L,mid),build(rc,mid+1,R),upd(p);
}
void change(int p,int L,int R,int x,ull w){
if(L==R){
dat[0][p]+=w,dat[1][p]+=w;
return;
}
if(x<=mid)change(lc,L,mid,x,w);
else change(rc,mid+1,R,x,w);
upd(p);
}
ull ask(int op,int p,int L,int R,int l,int r){
if(r<L||R<l)return 0;
if(l<=L&&R<=r){
if(op==0)return pw[L-l]*dat[op][p];
else return pw[r-R]*dat[op][p];
}
if(r<=mid)return ask(op,lc,L,mid,l,r);
else if(l>mid)return ask(op,rc,mid+1,R,l,r);
else return ask(op,lc,L,mid,l,r)+ask(op,rc,mid+1,R,l,r);
}
#undef lc
#undef rc
#undef mid
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>q>>k>>b;
b*=2;
for(int i=1;i<=n;i++){
cin>>a[i];
a[i]=a[i]*2-i*k;
}
for(int i=n;i;i--)a[i]-=a[i-1];
pw[0]=1;
for(int i=1;i<=n;i++)pw[i]=pw[i-1]*base;
build(1,1,n);
while(q--){
ull op,l,r,w,x;
cin>>op;
if(op==1){
cin>>l>>r>>w;w*=2;
change(1,1,n,l,w);
if(r+1<=n)change(1,1,n,r+1,-w);
}else{
cin>>x;
if(x==1||x==n||ask(0,1,1,n,x,x)+ask(0,1,1,n,x+1,x+1)!=b){
cout<<"0\n";
continue;
}
int l=2,r=min(x-1,n-x);
while(l<=r){
int mid=(l+r)>>1;
if(ask(0,1,1,n,x-mid+1,x-1)+ask(1,1,1,n,x+2,x+mid)!=0)r=mid-1;
else l=mid+1;
}
cout<<r<<endl;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 11808kb
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: -100
Wrong Answer
time: 11ms
memory: 11984kb
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 116 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 77 1 72 65 16 22 118 6 189 71 1 247 107 43 34 3 27 20 21 44 56 96 36 17 27 22 30 32 6 5 105 27 48 28 58 15 74 154 17 110 57 3 90 33 15 24 94 68 25 86 14 10 4 10 2 34 39 36 33 164 11 19 ...
result:
wrong answer 9th numbers differ - expected: '17', found: '116'