QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#784210 | #9727. Barkley III | Carucao | WA | 1ms | 11864kb | C++20 | 5.6kb | 2024-11-26 14:07:16 | 2024-11-26 14:07:17 |
Judging History
answer
#include<bits/stdc++.h>
#define ls i<<1
#define rs i<<1|1
#define fi first
#define se second
#define min amin
#define max amax
#define eb emplace_back
using namespace std;
using ll=long long;
using LL=__int128;
using pii=pair<int,int>;
const int N=4E6+10;
const ll inf=LLONG_MAX;
const int p=998244353;
template<typename T=int>T read(){T x;cin>>x;return x;}
template<typename U,typename V>U min(const U &x,const V &y){return x<y?x:y;}
template<typename U,typename V>U max(const U &x,const V &y){return y<x?x:y;}
template<typename U,typename ...V>U min(const U &x,const V &...y){return min(x,min(y...));}
template<typename U,typename ...V>U max(const U &x,const V &...y){return max(x,max(y...));}
template<typename U,typename V>bool cmin(U &x,const V &y){return y<x?x=y,true:false;}
template<typename U,typename V>bool cmax(U &x,const V &y){return x<y?x=y,true:false;}
template<typename U,typename ...V>bool cmin(U &x,const V &...y){return cmin(x,min(y...));}
template<typename U,typename ...V>bool cmax(U &x,const V &...y){return cmax(x,max(y...));}
template<typename U,typename V>U qpow(U x,V n){U y(1);for(;n;n>>=1,x*=x)if(n&1)y*=x;return y;}
ll sqrt_floor(const ll &x){ll l=0,r=inf;while(l+1^r){ll mid=l+r>>1;(x<mid*mid?r:l)=mid;}return l;}
ll sqrt_ceil(const ll &x){ll l=-1,r=inf;while(l+1^r){ll mid=l+r>>1;(mid*mid<x?l:r)=mid;}return r;}
istream &operator>>(istream &is,LL &x){string a;is>>a;bool k=a[0]=='-';if(k)a=a.substr(1);x=0;for(char &t:a)x=x*10+t-48;if(k)x=-x;return is;}
ostream &operator<<(ostream &os,LL x){if(x<0)os<<'-',x=-x;string a;do a+=x%10|48;while(x/=10);reverse(a.begin(),a.end());return os<<a;}
mt19937 rng(time(0));
struct mint{
int x;
mint():x(){}
mint(const int &x):x(x<0?x+p:x){}
mint inv()const{return qpow(*this,p-2);}
mint operator-()const{return mint(x?p-x:x);}
mint &operator+=(const mint &t){return (x+=t.x)<p?0:x-=p,*this;}
mint &operator-=(const mint &t){return (x-=t.x)<0?x+=p:0,*this;}
mint &operator*=(const mint &t){return x=ll(x)*t.x%p,*this;}
mint &operator/=(const mint &t){return *this*=t.inv();}
mint operator+(const mint &t)const{return mint(*this)+=t;}
mint operator-(const mint &t)const{return mint(*this)-=t;}
mint operator*(const mint &t)const{return mint(*this)*=t;}
mint operator/(const mint &t)const{return mint(*this)/=t;}
operator int()const{return x;}
bool operator==(const mint &t)const{return x==t.x;}
friend mint operator+(const mint &x,const int &y){return mint(x)+=y;}
friend mint operator-(const mint &x,const int &y){return mint(x)-=y;}
friend mint operator*(const mint &x,const int &y){return mint(x)*=y;}
friend mint operator/(const mint &x,const int &y){return mint(x)/=y;}
friend mint operator+(const int &x,const mint &y){return mint(x)+=y;}
friend mint operator-(const int &x,const mint &y){return mint(x)-=y;}
friend mint operator*(const int &x,const mint &y){return mint(x)*=y;}
friend mint operator/(const int &x,const mint &y){return mint(x)/=y;}
friend istream &operator>>(istream &is,mint &t){return is>>t.x;}
friend ostream &operator<<(ostream &os,const mint &t){return os<<t.x;}
};
using pll=pair<ll,ll>;
ll a[N],laz[N];
pll f[N];
bool leaf[N];
pll &operator+=(pll &x,const pll &y){
x.se|=y.se|x.fi&y.fi;
x.fi|=y.fi;
return x;
}
pll operator+(pll x,const pll &y){
return x+=y;
}
void calc(int i,ll w){
a[i]&=w;
if(leaf[i]){
f[i].fi=~a[i];
}
else{
laz[i]&=w;
f[i].fi|=~w;
f[i].se|=~w;
}
}
void push_down(int i){
if(laz[i]^inf){
calc(ls,laz[i]);
calc(rs,laz[i]);
laz[i]=inf;
}
}
void push_up(int i){
a[i]=a[ls]&a[rs];
f[i]=f[ls]+f[rs];
}
void build(int i,int l,int r){
if(l==r){
cin>>a[i];
f[i].fi=~a[i];
leaf[i]=true;
}
else{
laz[i]=inf;
int mid=l+r>>1;
build(ls,l,mid);
build(rs,mid+1,r);
push_up(i);
}
}
void And(int i,int l,int r,int x,int y,ll w){
if(l>y||r<x)return;
if(l>=x&&r<=y)return calc(i,w);
push_down(i);
int mid=l+r>>1;
And(ls,l,mid,x,y,w);
And(rs,mid+1,r,x,y,w);
push_up(i);
}
void modify(int i,int l,int r,int x,ll w){
if(l==r)return void(f[i].fi=~(a[i]=w));
push_down(i);
int mid=l+r>>1;
if(x<=mid)modify(ls,l,mid,x,w);
else modify(rs,mid+1,r,x,w);
push_up(i);
}
pll ask(int i,int l,int r,int x,int y){
if(l>y||r<x)return pll();
if(l>=x&&r<=y)return f[i];
push_down(i);
int mid=l+r>>1;
return ask(ls,l,mid,x,y)+ask(rs,mid+1,r,x,y);
}
int fd(int i,int l,int r,int x,int k){
if(l==r)return l;
push_down(i);
int mid=l+r>>1;
if(x<=mid&&~a[ls]>>k&1){
int t=fd(ls,l,mid,x,k);
if(t)return t;
}
return fd(rs,mid+1,r,x,k);
}
ll qry(int i,int l,int r,int x,int y){
if(l>y||r<x)return inf;
if(l>=x&&r<=y)return a[i];
push_down(i);
int mid=l+r>>1;
return qry(ls,l,mid,x,y)&qry(rs,mid+1,r,x,y);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin>>n>>m;
build(1,1,n);
while(m--){
int k,l,r;
ll x;
cin>>k>>l;
if(k==1){
cin>>r>>x;
And(1,1,n,l,r,x);
}
else if(k==2){
cin>>x;
modify(1,1,n,l,x);
}
else{
cin>>r;
pll w=ask(1,1,n,l,r);
ll t=w.fi&~w.se;
int u=t?fd(1,1,n,l,__lg(t)):l;
cout<<(qry(1,1,n,l,u-1)&qry(1,1,n,u+1,r))<<'\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 9872kb
input:
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
output:
7 6 7 3 3 8
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 9812kb
input:
10 10 6760061359215711796 1568091718842717482 1568091718842717482 1568091718842717482 5232472783634052627 8795942500783873690 1568091718842717482 1568091718842717482 1568091718842717482 1568091718842717482 1 3 5 7587422031989082829 3 6 10 1 7 8 5197616143400216932 2 4 2518604563805514908 2 2 4533959...
output:
1568091718842717482 35184908959744 176025477579040 8795942500783873690
result:
ok 4 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 11864kb
input:
100 100 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 625967318191814868 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072...
output:
576531121047601152 0 576460752303423488 4263579105072360993 153122391625564161 4263579105072360993 576531121047601152 77309673472 0 12952010752 0 1153488865559840256 3533641810948498945 67108864 576531718266945536 0 77309673472 1729382296723653632 0 1730020640668059136 3533641810948498945 0 56294995...
result:
wrong answer 2nd lines differ - expected: '1', found: '0'