QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747186 | #9727. Barkley III | Kir1same | Compile Error | / | / | C++20 | 3.8kb | 2024-11-14 16:32:20 | 2024-11-14 16:32:20 |
Judging History
你现在查看的是最新测评结果
- [2025-01-13 03:55:43]
- hack成功,自动添加数据
- (/hack/1447)
- [2024-11-14 16:32:20]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-11-14 16:32:20]
- 提交
answer
#include <bits/stdc++.h>
#define mid (l+r>>1)
#define ls(p) (p<<1)
#define rs(p) (p<<1|1)
#define ull unsigned long long
using namespace std;
const int N=1e6+10;
int n,q;ull a[N],maxnum;
struct TREE
{
ull f1,f2,g1,g2,s,tag;int leaf;
}tr[N<<2];
void pushup(TREE &p,TREE p1,TREE p2)
{
p.f1=p1.f1|p2.f1;
p.f2=p1.f2|p2.f2|(p1.f1&p2.f1);
p.g1=p1.g1|p1.g2;p.g2=p2.g1|p2.g2;
p.s=p1.s&p2.s;
}
void spread(int p)
{
tr[ls(p)].f1|=maxnum^tr[p].tag;
if(!tr[ls(p)].leaf) tr[ls(p)].f2|=maxnum^tr[p].tag;
tr[rs(p)].f1|=maxnum^tr[p].tag;
if(!tr[rs(p)].leaf) tr[rs(p)].f2|=maxnum^tr[p].tag;
tr[ls(p)].g1|=maxnum^tr[p].tag;
tr[ls(p)].g2|=maxnum^tr[p].tag;
tr[rs(p)].g1|=maxnum^tr[p].tag;
tr[rs(p)].g2|=maxnum^tr[p].tag;
tr[ls(p)].s&=tr[p].tag;
tr[rs(p)].s&=tr[p].tag;
tr[ls(p)].tag&=tr[p].tag;
tr[rs(p)].tag&=tr[p].tag;
tr[p].tag=maxnum;
}
void update1(int p,int l,int r,int ll,int rr,ull x)
{
if(ll<=l&&r<=rr)
{
tr[p].f1|=maxnum^x;
if(!tr[p].leaf) tr[p].f2|=maxnum^x;
tr[p].g1|=maxnum^x;
tr[p].g2|=maxnum^x;
tr[p].s&=x;
tr[p].tag&=x;
return;
}
spread(p);
if(ll<=mid) update1(ls(p),l,mid,ll,rr,x);
if(rr>mid) update1(rs(p),mid+1,r,ll,rr,x);
pushup(tr[p],tr[ls(p)],tr[rs(p)]);
}
void update2(int p,int l,int r,int pos,ull x)
{
if(l==r)
{
tr[p].f1=maxnum^x;
tr[p].f2=0;
tr[p].g1=maxnum^x;
tr[p].g2=maxnum^x;
tr[p].s=x;
return;
}
spread(p);
if(pos<=mid) update2(ls(p),l,mid,pos,x);
else update2(rs(p),mid+1,r,pos,x);
pushup(tr[p],tr[ls(p)],tr[rs(p)]);
}
TREE query(int p,int l,int r,int ll,int rr)
{
// cout<<"EMM"<<p<<" "<<l<<" "<<r<<" "<<ll<<" "<<rr<<" "<<tr[p].s<<endl;
if(ll<=l&&r<=rr) return tr[p];
spread(p);
if(ll<=mid&&rr>mid)
{
TREE tmp;
pushup(tmp,query(ls(p),l,mid,ll,rr),query(rs(p),mid+1,r,ll,rr));
return tmp;
}
else if(ll<=mid) return query(ls(p),l,mid,ll,rr);
else return query(rs(p),mid+1,r,ll,rr);
}
void build(int p,int l,int r)
{
tr[p].tag=maxnum;tr[p].leaf=0;
if(l==r)
{
tr[p].leaf=1;
tr[p].s=a[l];
tr[p].f1=maxnum^a[l];tr[p].f2=0;
tr[p].g1=tr[p].g2=maxnum^a[l];
return;
}
tr[p].leaf=0;
build(ls(p),l,mid);
build(rs(p),mid+1,r);
pushup(tr[p],tr[ls(p)],tr[rs(p)]);
// cout<<"EMM"<<p<<" "<<l<<" "<<r<<" "<<(maxnum^tr[p].f1)<<endl;
}
ull query1(int p,int l,int r,int ll,int rr,int k)
{
// cout<<"EMM"<<p<<" "<<l<<" "<<r<<" "<<tr[p].s<<endl;
if(ll<=l&&r<=rr)
{
if(l^r) spread(p);
// cout<<l<<" "<<r<<endl;
if(!(tr[p].f1&(1ull<<k))) return tr[p].s;
if(l==r)
{
return maxnum;
}
if(tr[p].g1&(1ull<<k)) return tr[rs(p)].s&query1(ls(p),l,mid,ll,rr,k);
else return tr[ls(p)].s&query1(rs(p),mid+1,r,ll,rr,k);
}
spread(p);
ull tmp=maxnum;
if(ll<=mid) tmp&=query1(ls(p),l,mid,ll,rr,k);
if(rr>mid) tmp&=query1(rs(p),mid+1,r,ll,rr,k);
// cout<<"WHY"<<tmp<<endl;
return tmp;
}
/\x14/胜利oid test(ull x)
//{
// cout<<"???";
// while(x)
// {
// cout<<(x&1);
// x>>=1;
// }
// cout<<endl;
//}
int main()
{
maxnum=-1;
scanf("%d %d",&n,&q);
for(int i=1;i<=n;i++)
scanf("%llu",&a[i]);
build(1,1,n);
while(q--)
{
int op,l,r;ull x;
scanf("%d",&op);
if(op==1)
{
scanf("%d %d %llu",&l,&r,&x);
update1(1,1,n,l,r,x);
}
if(op==2)
{
scanf("%d %llu",&l,&x);
update2(1,1,n,l,x);
}
if(op==3)
{
scanf("%d %d",&l,&r);
TREE tmp=query(1,1,n,l,r);ull ans=0;
// test(tmp.s);test(tmp.s);
// printf("%llb %llb\n",tmp.f1,tmp.f2);
// cout<<"EMM"<<tmp.f1<<" "<<tmp.f2<<endl;
for(int i=62;i>=0;i--)
{
if(!(tmp.f1&(1ull<<i)))
ans+=1ull<<i;
else
if(!(tmp.f2&(1ull<<i)))
{
ans=query1(1,1,n,l,r,i);
break;
}
}
printf("%llu\n",ans);
}
}
}
/*
5 9
7 7 7 6 7
3 1 5
2 1 3
3 1 5
3 1 3
1 1 2 3
3 1 3
2 2 8
3 1 3
3 1 2
*/
Details
answer.code:140:2: error: stray ‘\24’ in program 140 | /<U+0014>/<U+80DC><U+5229>oid test(ull x) | ^~~~~~~~ answer.code:140:1: error: expected unqualified-id before ‘/’ token 140 | /\x14/胜利oid test(ull x) | ^