QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#747853 | #9727. Barkley III | yylx | Compile Error | / | / | C++14 | 3.3kb | 2024-11-14 18:29:19 | 2024-11-14 18:29:23 |
Judging History
你现在查看的是最新测评结果
- [2025-01-13 03:55:43]
- hack成功,自动添加数据
- (/hack/1447)
- [2024-11-14 18:29:23]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-11-14 18:29:19]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
long long MAX=9223372036854775807
//long long MAX=15;
long long n,q,x,y,z,w,as[1000001];
pair<long long,long long> re;
struct tree
{
int l,r;
long long x,sum,lt=-1;
};
tree tr[4000001];
void build_tree(int cl,int cr,int ind)
{
tr[ind].l=cl;
tr[ind].r=cr;
if(cl==cr)
{
tr[ind].sum=as[cl];
tr[ind].x=MAX-as[cl];
return;
}
int m=cl+cr>>1;
build_tree(cl,m,ind<<1);
build_tree(m+1,cr,(ind<<1)+1);
tr[ind].sum=tr[ind<<1].sum&tr[(ind<<1)+1].sum;
tr[ind].x=(tr[ind<<1].sum&tr[(ind<<1)+1].x)|(tr[ind<<1].x&tr[(ind<<1)+1].sum);
}
void envalue(int ind,int v)
{
if(tr[ind].lt==-1) tr[ind].lt=v;
else tr[ind].lt&=v;
tr[ind].sum&=v;
if(tr[ind].l==tr[ind].r)
{
tr[ind].x=MAX-tr[ind].sum;
return;
}
tr[ind].x&=v;
return;
}
void push_down(int ind)
{
if(tr[ind].lt==-1) return;
envalue(ind<<1,tr[ind].lt);
envalue((ind<<1)+1,tr[ind].lt);
tr[ind].lt=-1;
return;
}
void add(int cl,int cr,int al,int ar,int ind,long long v)
{
if(cl>=al && cr<=ar)
{
envalue(ind,v);
return;
}
push_down(ind);
int m=cl+cr>>1;
if(m>=al) add(cl,m,al,ar,ind<<1,v);
if(m<ar) add(m+1,cr,al,ar,(ind<<1)+1,v);
tr[ind].sum=tr[ind<<1].sum&tr[(ind<<1)+1].sum;
tr[ind].x=(tr[ind<<1].sum&tr[(ind<<1)+1].x)|(tr[ind<<1].x&tr[(ind<<1)+1].sum);
return;
}
pair<long long,long long> findx(int cl,int cr,int al,int ar,int ind)
{
int m=cl+cr>>1;
if(cl>=al && cr<=ar) return make_pair(tr[ind].sum,tr[ind].x);
push_down(ind);
int s1=MAX,s2=MAX,x1=0,x2=0;
if(m>=al) {re=findx(cl,m,al,ar,ind<<1);s1=re.first;x1=re.second;}
if(m<ar) {re=findx(m+1,cr,al,ar,(ind<<1)+1);s2=re.first;x2=re.second;}
return make_pair(s1&s2,(s1&x2)|(s2&x1));
}
void modify(int cl,int cr,int p,int ind,int v)
{
if(cl==cr)
{
tr[ind].sum=v;
tr[ind].x=MAX-v;
return;
}
push_down(ind);
int m=cl+cr>>1;
if(m>=p) modify(cl,m,p,ind<<1,v);
else modify(m+1,cr,p,(ind<<1)+1,v);
tr[ind].sum=tr[ind<<1].sum&tr[(ind<<1)+1].sum;
tr[ind].x=(tr[ind<<1].sum&tr[(ind<<1)+1].x)|(tr[ind<<1].x&tr[(ind<<1)+1].sum);
}
long long locate(int cl,int cr,int al,int ar,int ind,int v)
{
int m=cl+cr>>1;
if(cl>=al && cr<=ar)
{
if((tr[ind].x&v)<=(v>>1)) return -1;
else
{
if(cl==cr) return tr[ind].sum;
else return max(locate(cl,m,al,ar,ind<<1,v),locate(m+1,cr,al,ar,(ind<<1)+1,v));
}
}
push_down(ind);
int l1=-1,l2=-1;
if(m>=al) l1=locate(cl,m,al,ar,ind<<1,v);
if(m<ar) l2=locate(m+1,cr,al,ar,(ind<<1)+1,v);
return max(l1,l2);
}
int main()
{
cin>>n>>q;
for(int i=1;i<=n;i+=1) cin>>as[i];
build_tree(1,n,1);
for(int i=1;i<=q;i+=1)
{
cin>>x;
if(x==1)
{
cin>>y>>z>>w;
add(1,n,y,z,1,w);
}
if(x==2)
{
cin>>y>>z;
modify(1,n,y,1,z);
}
if(x==3)
{
cin>>y>>z;
re=findx(1,n,y,z,1);
cout<<(re.first+(re.second&(MAX-locate(1,n,y,z,1,re.second))))<<endl;
}
}
return 0;
}
詳細信息
answer.code:9:1: error: expected ‘,’ or ‘;’ before ‘long’ 9 | long long n,q,x,y,z,w,as[1000001]; | ^~~~ answer.code: In function ‘void build_tree(int, int, int)’: answer.code:25:21: error: ‘as’ was not declared in this scope; did you mean ‘abs’? 25 | tr[ind].sum=as[cl]; | ^~ | abs answer.code: In function ‘int main()’: answer.code:123:10: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 123 | cin>>n>>q; | ^ | yn answer.code:123:13: error: ‘q’ was not declared in this scope 123 | cin>>n>>q; | ^ answer.code:124:33: error: ‘as’ was not declared in this scope; did you mean ‘abs’? 124 | for(int i=1;i<=n;i+=1) cin>>as[i]; | ^~ | abs answer.code:128:14: error: ‘x’ was not declared in this scope 128 | cin>>x; | ^ answer.code:131:18: error: ‘y’ was not declared in this scope 131 | cin>>y>>z>>w; | ^ answer.code:131:21: error: ‘z’ was not declared in this scope 131 | cin>>y>>z>>w; | ^ answer.code:131:24: error: ‘w’ was not declared in this scope 131 | cin>>y>>z>>w; | ^ answer.code:136:18: error: ‘y’ was not declared in this scope 136 | cin>>y>>z; | ^ answer.code:136:21: error: ‘z’ was not declared in this scope 136 | cin>>y>>z; | ^ answer.code:141:18: error: ‘y’ was not declared in this scope 141 | cin>>y>>z; | ^ answer.code:141:21: error: ‘z’ was not declared in this scope 141 | cin>>y>>z; | ^