QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#251727 | #7765. Xor Master | Adam_GS | 10 | 867ms | 140772kb | C++20 | 2.3kb | 2023-11-15 01:39:18 | 2023-11-15 01:39:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef unsigned long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
ll T[LIM], B[64];
int tr[4*LIM][64], lazy[4*LIM][64], n, N=1;
void spl(int v, int d, int k) {
lazy[2*v][k]^=lazy[v][k];
lazy[2*v+1][k]^=lazy[v][k];
tr[2*v][k]=d-tr[2*v][k];
tr[2*v+1][k]=d-tr[2*v+1][k];
lazy[v][k]=0;
}
void upd(int v, int l, int r, int a, int b, ll k) {
if(b<l || r<a) return;
if(a<=l && r<=b) {
rep(i, 64) if(k&((ll)1<<(ll)i)) {
tr[v][i]=(r-l+1)-tr[v][i];
lazy[v][i]^=1;
}
return;
}
rep(i, 64) if(lazy[v][i]) spl(v, r-l+1, i);
int mid=(l+r)/2;
upd(2*v, l, mid, a, b, k);
upd(2*v+1, mid+1, r, a, b, k);
rep(i, 64) tr[v][i]=tr[2*v][i]+tr[2*v+1][i];
}
ll cnt(int v, int l, int r, int a, int b, ll k) {
if(b<l || r<a) return 0;
if(a<=l && r<=b) {
ll ans=0;
rep(i, 64) if(k&((ll)1<<(ll)i)) ans+=(ll)(r-l+1-tr[v][i])<<(ll)i; else ans+=(ll)tr[v][i]<<(ll)i;
return ans;
}
rep(i, 64) if(lazy[v][i]) spl(v, r-l+1, i);
int mid=(l+r)/2;
return cnt(2*v, l, mid, a, b, k)+cnt(2*v+1, mid+1, r, a, b, k);
}
bool updb(ll x) {
for(int i=63; i>=0; --i) x=min(x, x^B[i]);
for(int i=63; i>=0; --i) if(x&((ll)1<<(ll)i)) {
B[i]=x;
return true;
}
return false;
}
ll g(ll x) {
for(int i=63; i>=0; --i) x=max(x, x^B[i]);
return x;
}
ll h(ll x) {
for(int i=63; i>=0; --i) x=min(x, x^B[i]);
return x;
}
void buduj() {
rep(i, 2*N) rep(j, 64) tr[i][j]=lazy[i][j]=0;
ll x=0;
rep(i, n) {
x^=T[i];
ll p=g(x);
rep(j, 64) if(p&((ll)1<<(ll)j)) tr[N+i][j]=1;
}
for(int i=N-1; i; --i) rep(j, 64) tr[i][j]=tr[2*i][j]+tr[2*i+1][j];
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int q;
cin >> n >> q;
while(N<n) N*=2;
rep(i, n) cin >> T[i];
buduj();
while(q--) {
int t;
cin >> t;
if(t==1) {
ll x, v;
cin >> x >> v; --x;
T[x]^=v;
upd(1, 0, N-1, x, n-1, h(v));
} else if(t==2) {
ll x;
cin >> x;
if(updb(x)) buduj();
} else {
int l, r;
cin >> l >> r; --l; --r;
cout << cnt(1, 0, N-1, l, r, 0) << '\n';
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 12540kb
input:
2000 2000 1860495733 462603674 3739839441 759356520 47330263 550811730 2301200895 989240351 2499503801 2624225494 2123076812 1180966826 238739434 488666688 784742950 2583466952 4111371941 2335988605 2583741355 933716686 1644403538 1970423306 304500250 905101643 1814942168 1136358764 88729799 1577263...
output:
907077811929 3578033749407 3147231999544 2030836353891 423713508489 1792147706412 1048435557156 2368819580222 1681650405890 1126879741380 2059292122849 1019892119697 2485553716841 2475527717245 2335332518372 3468054454338 2918397833177 1668791974422 1354304870506 428458457252 2189533667249 253319542...
result:
wrong answer 1st lines differ - expected: '867006634793', found: '907077811929'
Subtask #2:
score: 0
Memory Limit Exceeded
Test #5:
score: 0
Memory Limit Exceeded
input:
500000 100000 12261386944926786495 7846697792998647383 16622924885320463714 170129022271213944 12625257523700625864 7684671687986103560 11532026873918423068 1131776055566669037 8263146651412710501 17872572061246021001 5017109039248728310 11088626167542318645 13810119722795416818 10928315716094262229...
output:
14197877638720303124 9197233613626692918 59467631852361769 8109954515798926873 11781550165916749828 14534038436575220482 323540849739126135 16742637465741588372 981709383938694814 18433754716845351568 13054526266898637222 16243320842227363405 12520897685474514617 16933754808887997531 144247179834920...
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 10
Accepted
Test #15:
score: 10
Accepted
time: 851ms
memory: 139064kb
input:
100000 100000 860905160 3192911636 290327446 2020707113 959258245 454185039 421895589 1070265496 2218913641 1684685660 1206723673 2606734467 4247254571 3341954386 3805299640 1702270353 2472053741 2816060613 1307901348 2702949728 879391505 884661815 330738731 1575749344 1239158446 2099693858 67466644...
output:
208755389215975 125497785366837 162446748431411 63166834945113 33018804920229 89343160639243 36805816758195 40790494641758 13928126471189 267168502433672 191989403472418 276350936750564 11189666657474 133862444125402 92684260245650 179275392898572 46159208957881 232612971657325 184946588056252 11022...
result:
ok 49937 lines
Test #16:
score: 0
Accepted
time: 867ms
memory: 140720kb
input:
100000 100000 3000426759 1824979832 10575943 1641880522 143940604 1261846884 1440252673 1935901636 2652482829 470200294 2760667036 1220768939 3242608584 30882643 3358811662 1954487430 4180122469 4037250966 1441428251 65645189 4256227499 2434976018 1044356540 1620226231 1790468792 103643592 177914654...
output:
145524055862860 161441138955842 306257129346343 299241569554302 226683771328975 181478349880992 130902872439424 280739831883457 4613950888066 230458529036600 79448487784419 221626929814178 372553919558010 197240289390578 161723969896905 318321608389202 174341260990323 316468299413037 71567183240652 ...
result:
ok 49939 lines
Test #17:
score: 0
Accepted
time: 840ms
memory: 139160kb
input:
100000 100000 498518053 2395903916 3150345345 970832874 3209063924 918965752 719268408 671515184 3219866836 2211624912 4145355509 2996354339 4177997608 3629522427 1213935750 2323829632 3165425771 298491930 908110837 335150507 2730640728 1723129376 652211552 542768976 2794794671 3614541766 2502995608...
output:
260888209253328 220417527912855 82382666528415 205546503607350 135868918784651 83987999793156 230878751182064 61087943195861 228413465926535 283578798581409 21723069972011 139237220178662 110232569033326 176416307293587 344477122018860 268362176646883 115160165700192 374561042493460 322099679993279 ...
result:
ok 50165 lines
Test #18:
score: 0
Accepted
time: 834ms
memory: 139052kb
input:
100000 100000 3992377736 434272953 2992624759 2250120461 2826429649 1076646810 1973468088 793827622 2495303276 3051008910 461259433 807863154 899742425 2917748831 3777743530 2401888492 375547402 445106376 3978593719 1459330010 3512989180 138941241 257638089 2598569114 2184509605 2499713476 239125335...
output:
147448496111215 217893531933388 149751201282482 207237624790060 236297842537499 215103721410855 77304922769081 222323379784810 186478109354540 112876203505747 179420115108834 150190314932342 43670232007873 25887688561684 46014605520682 21167146272975 216254665421226 136814646622945 4186313114826 229...
result:
ok 50066 lines
Test #19:
score: 0
Accepted
time: 843ms
memory: 140772kb
input:
100000 100000 3179037198 1726433634 1170347124 1038182581 976465227 3428516821 2779258891 2172100746 2976741309 804773686 1819799408 2161144533 271279535 375735337 1495976758 1446095086 783591841 647495961 2978211107 4184592567 2538879833 1516802478 3667793825 3117167846 1421032731 399321258 2739042...
output:
14881117655388 285727776113744 96063693786679 42810374617026 288595074947863 280315397686375 289641204087564 112743323666062 186419939913803 111073514966384 130685514549648 254506212148884 101643204416767 253148324245449 95367927417 281948636745321 193523757014667 134607728490831 291309237374936 238...
result:
ok 50035 lines
Test #20:
score: 0
Accepted
time: 847ms
memory: 139088kb
input:
100000 100000 2837558084 270944129 1488717152 2392454072 470770792 2777133 722770864 3585689195 590024623 3488355822 17552172 1874212154 4168915873 1921182598 4147474167 2573985631 3517994287 748095291 1037232836 3370419592 1671928653 4030684268 641958463 1580906861 2996601090 3022839831 4219465735 ...
output:
48146023505073 199293116412251 16853038897970 261946024338866 293982581313722 20413002833952 275337254322097 23734082669358 304448299364826 207480800390891 209702100347470 107059294321865 67809987007145 31022679709752 231784403945102 191992113958559 71931140153873 318909802436554 308235637561914 480...
result:
ok 50340 lines
Test #21:
score: 0
Accepted
time: 842ms
memory: 140408kb
input:
100000 100000 364926614 1655853438 3186329604 2743661979 2747155766 1720061739 2439752943 937515084 2541570348 1831323174 2685307250 345381411 2570490374 1411159104 3124296940 1010675903 916623261 3920607778 1055185260 3605823397 3735681762 875120207 184660308 3070923245 4194650139 390860276 3773763...
output:
212343579500935 145743539929651 81469645915718 179691739954130 40183110135676 187234010931784 221570315189145 151009623141265 87859127080109 119598166244021 219492663052409 11708497011473 93783594707846 3576360455299 302012818573840 296265045459927 161349572929071 8052465444694 313371100072835 29316...
result:
ok 50029 lines
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #4:
100%
Accepted
Test #22:
score: 0
Time Limit Exceeded
input:
500000 100000 17875507896876852594 1231709150845899221 4118660995540143087 2819399476387881514 10658483116489758483 1552311792717328959 14473006677868328329 994640445028619787 3867235579009926064 13154180381468776383 13818624943002555745 15236156474893022124 8540629523994518030 18015042213820785602 ...
output:
10869073095452935323 4937957831895612347 8597855937100549826 4077084800767531060 13112867824279445332 5105048791714899665 17718481205510838851 12074525849086176152 6525859617975446449 2082310637126089892 9399666547046514786 16816388302879441034 17588209628777971111 1847567427746727327 84872524510475...
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%