QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#679081 | #9242. An Easy Geometry Problem | veg# | WA | 7ms | 7972kb | C++20 | 1.9kb | 2024-10-26 16:49:25 | 2024-10-26 16:49:25 |
Judging History
answer
#include<bits/stdc++.h>
#define ls(p) p<<1
#define rs(p) p<<1|1
#define ull unsigned long long
const int base=998244353;
using namespace std;
const int N=2e5+5;
ull mi[N];
int n,q,B,k,a[N],b[N];
struct A{
ull c[N<<2];
void up(int p) {
c[p]=c[ls(p)]+c[rs(p)];
}
void add(int p,int l,int r,int x,int y) {
if(l==r) {
c[p]+=(ull)y*mi[x];
return;
}
int mid=l+r>>1;
if(x<=mid) add(ls(p),l,mid,x,y);
else add(rs(p),mid+1,r,x,y);
up(p);
}
ull ask(int p,int l,int r,int x,int y) {
if(l==x&&r==y) return c[p];
int mid=l+r>>1;
if(y<=mid) return ask(ls(p),l,mid,x,y);
if(x>mid) return ask(rs(p),mid+1,r,x,y);
return ask(ls(p),l,mid,x,mid)+ask(rs(p),mid+1,r,mid+1,y);
}
}t1,t2;
bool check(int i,int mid) {
return mi[n-i]*t1.ask(1,1,n,i+2,i+mid)==mi[i]*t2.ask(1,1,n,n-i+2,n-i+mid);
}
int main(){
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
scanf("%d%d%d%d",&n,&q,&k,&B);
for(int i=1;i<=n;++i) scanf("%d",&a[i]);
mi[0]=1;
for(int i=1;i<=n;++i) {
mi[i]=mi[i-1]*base;
}
for(int i=1;i<=n;++i) {
b[i]=a[i]-a[i-1];
t1.add(1,1,n,i,b[i]);
t2.add(1,1,n,n-i+1,k-b[i]);
}
while(q--) {
int op; scanf("%d",&op);
if(op==1) {
int l,r,v; scanf("%d%d%d",&l,&r,&v);
b[r+1]-=v; t1.add(1,1,n,r+1,-v);
t2.add(1,1,n,n-r,v);
b[l]+=v; t1.add(1,1,n,l,v);
t2.add(1,1,n,n-l+1,-v);
} else {
int i; scanf("%d",&i);
if(n-i==0||i==1||b[i+1]+b[i]!=B+k) {
puts("0");
continue;
} else {
/* if(i==3) {
for(int i=1;i<=n;++i) {
printf("%d ",b[i]);
}
puts("");
printf("%d\n",check(3,2));
printf("%llu\n",t1.ask(1,1,n,3+2,3+2));
printf(" %llu\n",t2.ask(1,1,n,n-3+2,n-3+2));
} */
int l=2,r=min(n-i,i-1),ans=1;
while(l<=r) {
int mid=l+r>>1;
if(check(i,mid)) ans=mid,l=mid+1;
else r=mid-1;
}
printf("%d\n",ans);
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7972kb
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: 7ms
memory: 6100kb
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:
wrong answer 936th numbers differ - expected: '4', found: '18'