QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610927 | #9242. An Easy Geometry Problem | i0stream | WA | 44ms | 10152kb | C++14 | 3.1kb | 2024-10-04 18:04:42 | 2024-10-04 18:04:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2*1e5+100;
const ll B=13331;
const ll P1=1000000007;
const ll P2=998244353;
ll tag[N<<2],a[N];
int n,Q,l,r,t,op;
ll k,b,v;
struct node{
ll x,y;
}trl[N<<2],trr[N<<2],pre[N];
const node nb=(node){356114031,346202824};
ll read(){
ll flag=1,x=0,c=getchar();
while (c<'0' || c>'9'){if (c=='-') flag=-1;c=getchar();}
while (c>='0' && c<='9') x=x*10+c-48,c=getchar();
return x*flag;
}
inline node pl(node a,node b){return (node){(a.x+b.x)%P1,(a.y+b.y)%P2};}
inline node ml(node a,node b){return (node){(a.x*b.x)%P1,(a.y*b.y)%P2};}
inline node mn(node a,node b){return (node){(a.x-b.x+P1)%P1,(a.y-b.y+P2)%P2};}
inline bool eq(node a,node b){return a.x==b.x && a.y==b.y;}
inline node trans(ll a){return (node){a%P1,a%P2};}
void pushup(int t,int l,int r){
int mid=l+r>>1;
trl[t]=pl(ml(trl[t<<1],pre[r-mid]),trl[t<<1|1]);
trr[t]=pl(trr[t<<1],ml(trr[t<<1|1],pre[mid-l+1]));
}
void pushdown(int t,int l,int r){
int mid=l+r>>1;
tag[t<<1]+=tag[t];
tag[t<<1|1]+=tag[t];
trl[t<<1]=pl(trl[t<<1],ml(trans(tag[t]),ml(mn(pre[mid-l+1],trans(1)),nb)));
trl[t<<1|1]=pl(trl[t<<1|1],ml(trans(tag[t]),ml(mn(pre[r-mid],trans(1)),nb)));
trr[t<<1]=pl(trr[t<<1],ml(trans(tag[t]),ml(mn(pre[mid-l+1],trans(1)),nb)));
trr[t<<1|1]=pl(trr[t<<1|1],ml(trans(tag[t]),ml(mn(pre[r-mid],trans(1)),nb)));
tag[t]=0;
}
void build(int t,int l,int r){
if (l==r){
trl[t]=trans(a[l]);
trr[t]=trans(a[l]);
return;
}
int mid=l+r>>1;
build(t<<1,l,mid);
build(t<<1|1,mid+1,r);
pushup(t,l,r);
}
void modify(int t,int l,int r,int x,int y,ll k){
if (x<=l && r<=y){
tag[t]+=k;
trl[t]=pl(trl[t],ml(trans(k),ml(mn(pre[r-l+1],trans(1)),nb)));
trr[t]=pl(trr[t],ml(trans(k),ml(mn(pre[r-l+1],trans(1)),nb)));
return;
}
pushdown(t,l,r);
int mid=l+r>>1;
if (x<=mid) modify(t<<1,l,mid,x,y,k);
if (y>mid) modify(t<<1|1,mid+1,r,x,y,k);
pushup(t,l,r);
}
node queryl(int t,int l,int r,int x,int y){
if (x==l && r==y) return trl[t];
pushdown(t,l,r);
int mid=l+r>>1;
if (y<=mid) return queryl(t<<1,l,mid,x,y);
if (x>mid) return queryl(t<<1|1,mid+1,r,x,y);
return pl(ml(queryl(t<<1,l,mid,x,mid),pre[y-mid]),queryl(t<<1|1,mid+1,r,mid+1,y));
}
node queryr(int t,int l,int r,int x,int y){
if (x==l && r==y) return trr[t];
pushdown(t,l,r);
int mid=l+r>>1;
if (y<=mid) return queryr(t<<1,l,mid,x,y);
if (x>mid) return queryr(t<<1|1,mid+1,r,x,y);
return pl(queryr(t<<1,l,mid,x,mid),ml(queryr(t<<1|1,mid+1,r,mid+1,y),pre[mid-l+1]));
}
int main(){
n=read();Q=read();k=read();b=read();
pre[0]=(node){1,1};
for (int i=1;i<=n;i++){
a[i]=read()*2-i*k;
pre[i]=ml(pre[i-1],trans(B));
}
build(1,1,n);
while (Q--){
op=read();
if (op==1){
l=read();r=read();v=read()*2;
modify(1,1,n,l,r,v);
}else{
t=read();
modify(1,1,n,1,t-1,b*2);
int l=0,r=min(t-1,n-t)+1;
while (l<r){
if (l==r-1) break;
int mid=l+r>>1;
if (eq(queryr(1,1,n,t-mid,t-1),queryl(1,1,n,t+1,t+mid))) l=mid;
else r=mid;
}
printf("%d\n",l);
modify(1,1,n,1,t-1,-b*2);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 10032kb
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: 44ms
memory: 10152kb
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 8 1 1 1 2 2 4 1 2 1 2 2 3 2 12 1 1 4 1 13 1 6 2 1 1 6 1 2 2 14 2 1 2 1 5 2 1 3 5 1 11 3 1 2 2 2 1 2 1 1 2 11 1 1 1 2 2 1 2 1 2 2 1 1 2 1 1 1 1 1 3 2 1 1 5 1 5 1 1 1 1 1 3 3 2 1 1 1 1 3 1 1 1 4 1 2 1 4 1 3 1 7 1 4 14 2 7 1 1 1 1 2 11 1 3 2 1 1 2 1 3 2 6 1 2 1 3 3 2 2 1 2 1 2 0 1 9 2 4 1 4 1 2 2 1 1...
result:
wrong answer 2nd numbers differ - expected: '304', found: '8'