QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863768 | #9727. Barkley III | 2018ljw# | TL | 909ms | 62696kb | C++14 | 2.7kb | 2025-01-19 22:06:18 | 2025-01-19 22:06:28 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
const long long mx=((1ll<<62)-1)*2+1;
using namespace std;
int n;
long long a[1000001],tag[4194305];
struct tree{
long long asum,st;
}tre[4194305];
inline tree operator+(tree x,tree y){
return {x.asum&y.asum,(x.asum&y.st)|(x.st&y.asum)};
}
void build(int k,int l,int r){
tag[k]=mx;
if(l==r){
tre[k]={a[l],mx^a[l]};
return;
}
int mid=l+r>>1;
build(k<<1,l,mid);
build(k<<1|1,mid+1,r);
tre[k]=tre[k<<1]+tre[k<<1|1];
}
inline void add(int k,int l,int r,long long v){
tre[k].asum&=v;
if(l==r)tre[k].st=mx^tre[k].asum;
else tre[k].st&=v;
tag[k]&=v;
}
inline void pushdown(int k,int l,int r){
if(tag[k]==mx)return;
long long v=tag[k];tag[k]=mx;
int mid=l+r>>1;
add(k<<1,l,mid,v);
add(k<<1|1,mid+1,r,v);
}
void modify(int k,int l,int r,int x,int y,long long v){
if(l>=x&&r<=y){
add(k,l,r,v);
return;
}
pushdown(k,l,r);
int mid=l+r>>1;
if(x<=mid)modify(k<<1,l,mid,x,y,v);
if(mid<y)modify(k<<1|1,mid+1,r,x,y,v);
tre[k]=tre[k<<1]+tre[k<<1|1];
}
void change(int k,int l,int r,int x,long long v){
if(l==r){
tre[k]={v,mx^v};
return;
}
pushdown(k,l,r);
int mid=l+r>>1;
if(x<=mid)change(k<<1,l,mid,x,v);
else change(k<<1|1,mid+1,r,x,v);
tre[k]=tre[k<<1]+tre[k<<1|1];
}
tree query(int k,int l,int r,int x,int y){
if(l>=x&&r<=y)return tre[k];
pushdown(k,l,r);
int mid=l+r>>1;
tree res={mx,0};
if(x<=mid)res=query(k<<1,l,mid,x,y);
if(mid<y)res=res+query(k<<1|1,mid+1,r,x,y);
return res;
}
int qpos(int k,int l,int r,int x,int y,long long pl){
if(l==r){
if(tre[k].asum&pl)return -1;
return l;
}
pushdown(k,l,r);
int mid=l+r>>1;
if(x>mid)return qpos(k<<1|1,mid+1,r,x,y,pl);
if(mid>=y)return qpos(k<<1,l,mid,x,y,pl);
int lres=qpos(k<<1,l,mid,x,y,pl);
if(lres==-1)return qpos(k<<1|1,mid+1,r,x,y,pl);
else return lres;
}
inline long long read(){
long long x=0;
char c=getchar();
while(c>'9'||c<'0')c=getchar();
while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
return x;
}
int main(){
int i,q;
n=read();q=read();
for(i=1;i<=n;i++)a[i]=read();
build(1,1,n);
while(q--){
int op,l,r;
long long v;
op=read();l=read();
if(op==1){
r=read();v=read();
modify(1,1,n,l,r,v);
}
if(op==2){
v=read();
change(1,1,n,l,v);
}
if(op==3){
r=read();
tree res=query(1,1,n,l,r);
if(!res.st){
printf("%lld\n",res.asum);
continue;
}
long long mul=1;
while(res.st){
res.st/=2;
if(res.st)mul*=2;
}
int p=qpos(1,1,n,l,r,mul);
tree ans={mx,0};
if(p!=l)ans=ans+query(1,1,n,l,p-1);
if(p!=r)ans=ans+query(1,1,n,p+1,r);
printf("%lld\n",ans.asum);
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5728kb
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: 0ms
memory: 5548kb
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: 0
Accepted
time: 0ms
memory: 5732kb
input:
100 100 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 625967318191814868 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072360993 4263579105072...
output:
576531121047601152 1 576460752303423488 4263579105072360993 1306043896232411137 4263579105072360993 576531121047601152 633397148123136 0 1153488865559840256 1152922054496880128 1730020640668059136 3533641810948498945 67108864 1730020640668059136 0 633397148123136 1729382296723653632 0 17300206406680...
result:
ok 78 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 5732kb
input:
1000 1000 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3368486440884437410 3639580211161047627 3368486440884437410 3368486440884437410 3368486440...
output:
3368486440884437410 3368486440884437410 3368486440884437410 2251799981457408 0 0 3368486440884437410 0 3326828075601101216 592509842556584322 0 0 0 0 0 0 37154696925806592 0 0 0 3368486440884437410 0 0 3368486440884437410 0 578998425140330496 0 0 134217728 0 3368486440884437410 2306405959167115264 0...
result:
ok 732 lines
Test #5:
score: 0
Accepted
time: 47ms
memory: 13248kb
input:
100000 100000 4364025563773184234 7745126251050571359 5111681002836044963 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7745126251050571359 7222555899134537718 7745126251050571359 686495...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4613942216556019776 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 75105 lines
Test #6:
score: 0
Accepted
time: 671ms
memory: 62696kb
input:
1000000 1000000 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485203341817263234 5485...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8796093022208 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 576460754450907136 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 749866 lines
Test #7:
score: 0
Accepted
time: 662ms
memory: 62664kb
input:
1000000 1000000 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 6478641409915854014 815888006180307319 6478641409915854014 6478641409915854014 37784...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 749822 lines
Test #8:
score: 0
Accepted
time: 662ms
memory: 62664kb
input:
1000000 1000000 8129239286682760854 3981028880940170401 2535635990161413927 8316479514668652599 5147316903112543089 4630570098268037408 8505388156841465368 2203883581249948495 581610100009626881 5079268521394939 1476469952815397946 4914699404295060276 4440084747042452220 2702894635900623841 90540586...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 749812 lines
Test #9:
score: 0
Accepted
time: 680ms
memory: 62664kb
input:
1000000 1000000 7320373167365396487 7320373167365396487 937526916087788458 7320373167365396487 7320373167365396487 7320373167365396487 6758767667984378025 7320373167365396487 7320373167365396487 7320373167365396487 5687396935769483606 1467370155631201061 3556475128226340387 2212274051825085385 77978...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 748638 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 5476kb
input:
2 2 3937866409909043622 2873041425983999763 2 2 3645842096674595914 2 1 5018240021376355677
output:
result:
ok 0 lines
Test #11:
score: 0
Accepted
time: 677ms
memory: 62648kb
input:
1000000 1000000 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900813446099088166 4900...
output:
4900813446099088166 4899930503817200418 4900813446099088166 4899916948900413730 4899916948900413730 4899930503817200418 4899930503817200418 4899930503817200418 4899930503817200418 4900813446099088166 288230380446679040 288230380446679040 4899930503817200418 4899930503817200418 0 768 768 288230724044...
result:
ok 748697 lines
Test #12:
score: 0
Accepted
time: 698ms
memory: 62528kb
input:
1000000 1000000 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896682234503638342 4896...
output:
4896682234503638342 4896682234503638342 4896682234503638342 82333682484117506 4896682234503638342 82333682484117506 9150188513918978 9150188513918978 4896682234503638342 4896682234503638342 9150188513918978 4896682234503638342 9150188513918978 4896682234503638342 4896682234503638342 9150188513918978...
result:
ok 748737 lines
Test #13:
score: 0
Accepted
time: 677ms
memory: 62676kb
input:
1000000 1000000 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828086749355423563 5828...
output:
5828086749355423563 8192 0 0 1152921504793493761 0 0 0 134217728 5828086749355423563 4647719230811407937 0 0 0 0 4647719230811407937 4611686018427396096 0 0 4415226380288 0 0 0 0 4665729214006427657 0 0 4665729213955833856 0 4665733612138661120 0 0 4611686018429485056 4666015104295802624 0 0 0 0 0 4...
result:
ok 749804 lines
Test #14:
score: 0
Accepted
time: 695ms
memory: 62520kb
input:
1000000 1000000 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970703737173261435 1970...
output:
18014398510006272 1970703737173261435 1970703737173261435 18014398510006272 1170935903116331008 1170935903116331008 1242993501449496576 72057598332903424 72127962782629888 72057594037927936 72057598333165568 70405251923968 0 0 0 0 0 0 0 673367418922088530 72127962782892032 18014398509481984 0 704052...
result:
ok 749806 lines
Test #15:
score: 0
Accepted
time: 687ms
memory: 62676kb
input:
1000000 1000000 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268538845505400998 1268...
output:
1191203210145169410 0 0 0 0 0 0 0 8589934592 705069918064678 704786953404416 0 0 1268538845505400998 1268538845505400998 4503633987117056 8589934592 0 633318697730048 2251804108783616 0 0 0 0 4503599627374592 0 0 0 0 704791248371712 1099511627776 0 0 0 1268538845505400998 0 0 633318731153408 1268538...
result:
ok 749818 lines
Test #16:
score: 0
Accepted
time: 676ms
memory: 62536kb
input:
1000000 1000000 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796374617094329340 8796...
output:
0 0 0 0 0 0 0 0 0 0 4612249037637189632 0 0 0 0 0 0 144115189706063880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8219350795484238412 0 0 0 536870912 0 0 0 0 0 0 8214847195317895748 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 144115188092633600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 749921 lines
Test #17:
score: 0
Accepted
time: 682ms
memory: 62656kb
input:
1000000 1000000 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639525139600828208 1639...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 324259173170675712 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 288231492843216896 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 144115188075864064 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 749798 lines
Test #18:
score: 0
Accepted
time: 733ms
memory: 62648kb
input:
1000000 1000000 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451...
output:
504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866451 292733989738811392 504297928904866451 504297928904866451 504297928904866451 504297928904866451 504297928904866...
result:
ok 332866 lines
Test #19:
score: 0
Accepted
time: 909ms
memory: 62684kb
input:
1000000 1000000 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984855923226151208 2984...
output:
2984855923226151208
result:
ok single line: '2984855923226151208'
Test #20:
score: 0
Accepted
time: 471ms
memory: 62532kb
input:
1000000 1000000 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067242734448201478 2067...
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 610ms
memory: 62540kb
input:
1000000 1000000 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549...
output:
4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 4549453206535718492 ...
result:
ok 1000000 lines
Test #22:
score: 0
Accepted
time: 748ms
memory: 62672kb
input:
1000000 1000000 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275...
output:
508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316275 508429140500316...
result:
ok 749894 lines
Test #23:
score: 0
Accepted
time: 728ms
memory: 62532kb
input:
1000000 1000000 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184554809109693663 6184...
output:
72057594037927936 108438303632146450 5819200270512603152 396527890631622850 4683745811488571528 6184554809109693663 0 72057594037927936 108438303632146450 6184554809109693663 6184554809109693663 72059793061183624 36099165763141632 4683745811488571528 6184554809109693663 6184554809109693663 720575940...
result:
ok 332716 lines
Test #24:
score: 0
Accepted
time: 893ms
memory: 62660kb
input:
1000000 1000000 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665112799136011124 8665...
output:
8665112799136011124
result:
ok single line: '8665112799136011124'
Test #25:
score: 0
Accepted
time: 471ms
memory: 62680kb
input:
1000000 1000000 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747499610358061394 7747...
output:
0
result:
ok single line: '0'
Test #26:
score: -100
Time Limit Exceeded
input:
1000000 1000000 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006...
output:
1006338049885769895 1006338049885769895 865598272308383749 1006338049885769895 586620239750365190 1006338049885769895 1006338049885769895 577586652210266114 613615520096321538 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1006338049885769895 1125899906842624 1006338...