QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786753#2813. WeirdtreeWilliamxzh0 49ms40556kbC++233.2kb2024-11-26 23:16:582024-11-26 23:17:06

Judging History

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

  • [2024-11-26 23:17:06]
  • 评测
  • 测评结果:0
  • 用时:49ms
  • 内存:40556kb
  • [2024-11-26 23:16:58]
  • 提交

answer

#include <bits/stdc++.h>
//#include "weirdtree.h"
#define il inline
using namespace std;
/*void initialise(int nn,int mm,int hh[]);
void cut(int l,int r,int k);
void magic(int i,int x);
long long inspect(int l,int r);*/
typedef long long ll;
il int read(){
    int x=0,c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) x=x*10+c-48,c=getchar();
    return x;
}
const int N=3e5+5,inf=1e9;
int n,m,a[N];
struct node{
    int mx,c,se;ll s;
    il node(){mx=c=se=0,s=0ll;}
}t[N<<2];int tag[N<<2];
il node merge(node x,node y){
    node z;z.s=x.s+y.s;
    if(x.mx>y.mx) z.mx=x.mx,z.c=x.c,z.se=max(x.se,y.mx);
    else if(x.mx<y.mx) z.mx=y.mx,z.c=y.c,z.se=max(x.mx,y.se);
    else z.mx=x.mx,z.c=x.c+y.c,z.se=max(x.se,y.se);
    return z;
}
il void pushup(int x){t[x]=merge(t[x<<1],t[x<<1|1]);}
il void maketag(int x,int w){if(w<t[x].mx) t[x].s-=1ll*(t[x].mx-w)*t[x].c,t[x].mx=w,tag[x]=w;}
il void pushdown(int x){if(tag[x]!=-inf) maketag(x<<1,tag[x]),maketag(x<<1|1,tag[x]),tag[x]=-inf;}
il void init(int x,int v){t[x].mx=v,t[x].c=1,t[x].se=-inf,t[x].s=1ll*v;}
void build(int x,int l,int r){
    tag[x]=-inf;
    if(l==r){init(x,a[l]);return ;}
    int mid=(l+r)>>1;
    build(x<<1,l,mid),build(x<<1|1,mid+1,r);
    pushup(x);
}
void update(int x,int l,int r,int p,int v){
    if(l==r){init(x,v);return ;}
    int mid=(l+r)>>1;pushdown(x);
    if(p<=mid) update(x<<1,l,mid,p,v);
    else update(x<<1|1,mid+1,r,p,v);
    pushup(x);
}
void change(int x,int l,int r,int L,int R,int &k,int w){
    if(t[x].mx<w || k<=0) return ;
    if(l>=L && r<=R && ((w-1>t[x].se && k>=t[x].c) || l==r)){maketag(x,w-1),k-=t[x].c;return ;}
    int mid=(l+r)>>1;pushdown(x);
    if(L<=mid) change(x<<1,l,mid,L,R,k,w);
    if(R>mid) change(x<<1|1,mid+1,r,L,R,k,w);
    pushup(x);
}
void chmin(int x,int l,int r,int L,int R,int w){
    if(w>=t[x].mx) return ;
    if(l>=L && r<=R && (w>t[x].se || l==r)){maketag(x,w);return ;}
    int mid=(l+r)>>1;pushdown(x);
    if(L<=mid) chmin(x<<1,l,mid,L,R,w);
    if(R>mid) chmin(x<<1|1,mid+1,r,L,R,w);
    pushup(x);
}
node query(int x,int l,int r,int L,int R){
    if(l>=L && r<=R) return t[x];
    int mid=(l+r)>>1;pushdown(x);
    if(L>mid) return query(x<<1|1,mid+1,r,L,R);
    else if(R<=mid) return query(x<<1,l,mid,L,R);
    else return merge(query(x<<1,l,mid,L,R),query(x<<1|1,mid+1,r,L,R));
}
void initialise(int nn,int mm,int hh[]){
    n=nn,m=mm;for(int i=1;i<=n;++i) a[i]=hh[i];
    build(1,1,n);
}
void cut(int l,int r,int k){
    node cur;int x,y,z,u,v,w;
    while(k){
        cur=query(1,1,n,l,r);
        if(cur.mx<=0) break;
        if(k<cur.c) change(1,1,n,l,r,k,cur.mx);
        else x=max(cur.se,cur.mx-k/cur.c),chmin(1,1,n,l,r,x),k-=1ll*cur.c*(cur.mx-x);
    }
}
void magic(int x,int y){update(1,1,n,x,y);}
ll inspect(int l,int r){return query(1,1,n,l,r).s;}
//test:
/*int nn,mm,hh[N];
int opt,l,r,x,y,z,u,v,w;
int main(){
    scanf("%d%d",&nn,&mm);
    for(int i=1;i<=nn;++i) hh[i]=read();
    initialise(nn,mm,hh);
    while(mm--){
        opt=read();
        if(opt==1) l=read(),r=read(),x=read(),cut(l,r,x);
        else if(opt==2) x=read(),y=read(),magic(x,y);
        else l=read(),r=read(),printf("%lld\n",inspect(l,r));
    }
    return 0;
}*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 34384kb

input:

966 1000
188363740 589476690 819684757 475179567 162289921 733331939 680003760 423847214 703730312 291752235 351463201 937522268 64588573 399012809 272561165 599780539 83270822 164102043 624995073 120374612 678210514 488108346 941579981 767236037 850406512 515467244 934426708 262361378 733612602 464...

output:

Unauthorized output

result:

wrong answer 1st lines differ - expected: '99386228771', found: 'Unauthorized output'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 36484kb

input:

937 1000
631216009 869613152 930472391 565464603 615860285 225788550 621532305 671044759 686011029 102483970 507799388 976017264 586239272 91471532 773404833 981261100 664781538 691746892 973047425 562711051 792865846 686480962 800771605 626015452 783329411 478894142 826983440 279108379 994766235 23...

output:

Unauthorized output

result:

wrong answer 1st lines differ - expected: '95606780168', found: 'Unauthorized output'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 49ms
memory: 40556kb

input:

279629 300000
864485544 147664426 873456004 602824795 902744016 20056943 260905686 609162276 241739883 338354289 437560714 444081255 584613844 200551305 963158452 282143442 169245526 10832409 265203076 576549337 275863148 94296798 887754059 15388512 25015579 800125936 979301246 68177101 30414420 446...

output:

Unauthorized output

result:

wrong answer 1st lines differ - expected: '139687223836955', found: 'Unauthorized output'

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%