QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567403 | #9242. An Easy Geometry Problem | ucup-team3519 | WA | 11ms | 21340kb | C++20 | 2.7kb | 2024-09-16 11:46:41 | 2024-09-16 11:46:41 |
Judging History
answer
#include <bits/stdc++.h>
#define N 200011
typedef long long LL;
using namespace std;
int n,q,k,b,a[N];
const LL mod = 444445555566666677;
const int P[2]={1028838407,1013333903};
LL MOD(LL x) {
if(x >= mod) x -= mod;
if(x < 0) x += mod;
return x;
}
struct mint{LL hs; mint(LL x) {x %= mod, MOD(x), hs = x;} mint() {hs = 0;}};
mint operator+(mint a,mint b){return {MOD(a.hs + b.hs)};}
mint operator-(mint a,mint b){return {MOD(a.hs - b.hs)};}
mint operator*(mint a,mint b){return {(__int128_t)a.hs * b.hs % mod};}
bool operator==(mint a,mint b){return a.hs == b.hs;}
mint pw[N],spw[N];
const int B=801801801;
mint lsum[N*4],rsum[N*4];
void pushup(int x,int L,int R)
{
int M=L+R>>1;
lsum[x]=lsum[x<<1]*pw[R-M]+lsum[x<<1|1];
rsum[x]=rsum[x<<1]+rsum[x<<1|1]*pw[M-L+1];
}
int tag[N*4];
void apply(int x,int p,int L,int R)
{
lsum[x]=lsum[x]+p*spw[R-L];
rsum[x]=rsum[x]+p*spw[R-L];
tag[x]+=p;
}
void pushdown(int x,int L,int R)
{
if(tag[x])
{
apply(x<<1,tag[x],L,L+R>>1);
apply(x<<1|1,tag[x],(L+R>>1)+1,R);
tag[x]=0;
}
}
void build(int L,int R,int x)
{
if(L==R){lsum[x]=rsum[x]=a[L]-(k/2)*L;return;}
build(L,L+R>>1,x<<1);build((L+R>>1)+1,R,x<<1|1);pushup(x,L,R);
}
mint lquery(int l,int r,int L,int R,int x)
{
if(l<=L&&R<=r)return lsum[x];pushdown(x,L,R);
if(l<=L+R>>1&&r>L+R>>1)
{
mint lv=lquery(l,r,L,L+R>>1,x<<1);
mint rv=lquery(l,r,(L+R>>1)+1,R,x<<1|1);
return lv*pw[min(r,R)-(L+R>>1)]+rv;
}
if(l<=L+R>>1)return lquery(l,r,L,L+R>>1,x<<1);return lquery(l,r,(L+R>>1)+1,R,x<<1|1);
}
mint rquery(int l,int r,int L,int R,int x)
{
if(l<=L&&R<=r)return rsum[x];pushdown(x,L,R);
if(l<=L+R>>1&&r>L+R>>1)
{
mint lv=rquery(l,r,L,L+R>>1,x<<1);
mint rv=rquery(l,r,(L+R>>1)+1,R,x<<1|1);
return rv*pw[(L+R>>1)-max(l,L)+1]+lv;
}
if(l<=L+R>>1)return rquery(l,r,L,L+R>>1,x<<1);return rquery(l,r,(L+R>>1)+1,R,x<<1|1);
}
void add(int l,int r,int p,int L,int R,int x)
{
if(l<=L&&R<=r){apply(x,p,L,R);return;}pushdown(x,L,R);
if(l<=L+R>>1)add(l,r,p,L,L+R>>1,x<<1);if(r>L+R>>1)add(l,r,p,(L+R>>1)+1,R,x<<1|1);pushup(x,L,R);
}
int main()
{
scanf("%d%d%d%d",&n,&q,&k,&b);
for(int i=1;i<=n;++i)scanf("%d",a+i),a[i]*=2;
pw[0]=1;for(int i=1;i<N;++i)pw[i]=pw[i-1]*B;
spw[0]=1;for(int i=1;i<N;++i)spw[i]=spw[i-1]+pw[i];
k*=2;b*=2;
build(1,n,1);
while(q--)
{
int cmd;
scanf("%d",&cmd);
if(cmd==1)
{
int l,r,v;scanf("%d%d%d",&l,&r,&v);v*=2;
add(l,r,v,1,n,1);
}
else
{
int i;scanf("%d",&i);
int L=1,R=min(i-1,n-i),ans=0;
while(L<=R)
{
int M=L+R>>1;
if(lquery(i-M,i-1,1,n,1)+b*spw[M-1]==rquery(i+1,i+M,1,n,1))ans=M,L=M+1;else R=M-1;
}
printf("%d\n",ans);
}
}
fclose(stdin);fclose(stdout);return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 21340kb
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: 20448kb
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:
0 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 0 33 7 18 96 7 40 39 13 7 46 43 16 0 72 33 16 22 5 6 189 27 0 35 107 43 34 3 27 20 21 44 56 96 36 0 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 0 14 10 4 10 2 25 39 36 33 164 11 19 181 11 3...
result:
wrong answer 1st numbers differ - expected: '2', found: '0'