QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371100#7765. Xor Masterwsyear20 842ms285760kbC++173.8kb2024-03-29 23:51:132024-03-29 23:51:13

Judging History

你现在查看的是最新测评结果

  • [2024-03-29 23:51:13]
  • 评测
  • 测评结果:20
  • 用时:842ms
  • 内存:285760kb
  • [2024-03-29 23:51:13]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D("[Debug] "#__VA_ARGS__ " = "), \
              debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 500010;

struct node {
  int len, cnt[64];
  node() { }
  node(ull x) {
    len = 1;
    rep (i, 0, 63) cnt[i] = (x >> i & 1);
  }
  friend node operator+(node x, node y) {
    node res;
    res.len = x.len + y.len;
    rep (i, 0, 63) res.cnt[i] = x.cnt[i] + y.cnt[i];
    return res;
  }
  void flip(ull x) {
    rep (i, 0, 63) if (x >> i & 1) cnt[i] = len - cnt[i];
  }
} t[maxn << 2];

int n, q, lz[maxn << 2];
ull a[maxn], s[maxn], c[64], lst[64];

struct fwt {
  ull t[maxn];
  void upd(int x, ull v) { while (x <= n) t[x] ^= v, x += x & (-x); }
  ull qry(int x) { ull res = 0; while (x) res ^= t[x], x -= x & (-x); return res; }
} fwt;

void ins(ull x) {
  per (i, 63, 0) if (x >> i & 1) {
    if (!c[i]) { c[i] = x; return; }
    x ^= c[i];
  }
}

ull qmx(ull x) {
  per (i, 63, 0) chkmx(x, x ^ c[i]);
  return x;
}

ull qmn(ull x) {
  per (i, 63, 0) chkmn(x, x ^ c[i]);
  return x;
}

void xiao() {
  per (i, 63, 0) {
    per (j, i - 1, 0) if (c[i] >> j & 1) c[i] ^= c[j];
  }
}

#define mid ((l + r) >> 1)

void build(int c, int l, int r) {
  lz[c] = 0;
  if (l == r) return t[c] = qmx(s[l]), void();
  build(c << 1, l, mid), build(c << 1 | 1, mid + 1, r);
  t[c] = t[c << 1] + t[c << 1 | 1];
}

void down(int c, int l, int r) {
  if (!lz[c]) return;
  lz[c << 1] ^= lz[c], t[c << 1].flip(lz[c]);
  lz[c << 1 | 1] ^= lz[c], t[c << 1 | 1].flip(lz[c]);
  lz[c] = 0;
}

void upd(int c, int l, int r, int x, int y, ll v) {
  if (l == x && r == y) return t[c].flip(v), lz[c] ^= v, void();
  down(c, l, r);
  if (y <= mid) upd(c << 1, l, mid, x, y, v);
  else if (x > mid) upd(c << 1 | 1, mid + 1, r, x, y, v);
  else upd(c << 1, l, mid, x, mid, v), upd(c << 1 | 1, mid + 1, r, mid + 1, y, v);
  t[c] = t[c << 1] + t[c << 1 | 1];
}

node qry(int c, int l, int r, int x, int y) {
  if (l == x && r == y) return t[c];
  down(c, l, r);
  if (y <= mid) return qry(c << 1, l, mid, x, y);
  else if (x > mid) return qry(c << 1 | 1, mid + 1, r, x, y);
  else return qry(c << 1, l, mid, x, mid) + qry(c << 1 | 1, mid + 1, r, mid + 1, y);
}

#undef mid

void rebuild() {
  rep (i, 1, n) s[i] = s[i - 1] ^ a[i];
  build(1, 1, n);
}

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> q;
  rep (i, 1, n) cin >> a[i], fwt.upd(i, a[i]);
  rebuild();
  while (q--) {
    int op, x, y;
    ull val;
    cin >> op;
    if (op == 1) {
      cin >> x >> val, a[x] ^= val, fwt.upd(x, val);
      upd(1, 1, n, x, n, qmn(val));
    } else if (op == 2) {
      cin >> val, memcpy(lst, c, sizeof(lst));
      ins(val), xiao();
      bool diff = 0;
      rep (i, 0, 63) if (c[i] != lst[i]) diff = 1;
      if (diff) rebuild();
    } else {
      cin >> x >> y, val = fwt.qry(x - 1), val = qmn(val);
      node res = qry(1, 1, n, x, y);
      ull ans = 0;
      rep (i, 0, 63) {
        int cnt = res.cnt[i];
        if (val >> i & 1) cnt = res.len - cnt;
        ans += ((1ull * cnt) << i);
      }
      cout << ans << '\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: 8ms
memory: 7792kb

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:

867006634793
823888790205
18446743631939703369
18446743214817177347
239792547603
18446743513715005606
55351278840
18446743806926045183
18446744005563075690
18446743528719363416
18446743635766108681
18446743588590690539
18446743394165140541
18446743092240089376
18446742165911111108
184467433661515081...

result:

wrong answer 2nd lines differ - expected: '3418049036989', found: '823888790205'

Subtask #2:

score: 10
Accepted

Test #5:

score: 10
Accepted
time: 416ms
memory: 285632kb

input:

500000 100000
12261386944926786495 7846697792998647383 16622924885320463714 170129022271213944 12625257523700625864 7684671687986103560 11532026873918423068 1131776055566669037 8263146651412710501 17872572061246021001 5017109039248728310 11088626167542318645 13810119722795416818 10928315716094262229...

output:

12337138966997790840
11593856511006775316
5653988472748567965
6281173414355612100
18027435777450732541
2903343914316621940
9422461876307420631
76690753587353877
798850376670823348
10137130634921141648
13914431888234873359
10192090671035653185
11569745711967074397
12303071505845046803
637460082558284...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 409ms
memory: 285680kb

input:

500000 100000
2401807279819923664 4864040262566555379 393321053390449880 4788516535106180899 16341781931596217301 5366313714490813917 8733414387771039303 3622005358527808423 6656486662369859494 5727971807004402567 1871899173840936696 6806964236526608687 9140220291662959979 14105070848567411114 13861...

output:

18076341197627185142
4362827643496160302
16458517423472358447
7372070120382179734
17124352181386485858
8256987425157370833
8991430708104334950
13354417317098667510
4820384361450081237
8337869045811888683
11434789480214872846
5853099668394635414
9921910794735540586
13822588195484916645
18016508410594...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 406ms
memory: 285648kb

input:

500000 100000
9957529645926737849 10057149949999768336 6838946770748251219 6896066705128063220 3993100902834799891 5323425649684667980 3760708431776774082 3860748130105828748 14761382969249249840 10936521060468005355 1875820140813348262 13560865738437472453 4392029878717344116 2698482518092628941 31...

output:

9038317550207043746
16505746615738128902
16113222356056267326
5313340055150519531
12389196059377873793
12520312844070623593
6947643770664034055
16237639987742643453
6175352167577923638
1984497765972065282
6098790840848813956
17485586471573206926
17056253743695232969
18412276874594508522
124977750289...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 429ms
memory: 285640kb

input:

500000 100000
5166592157828364085 8315993781810560457 7015464858242879867 9462293143600642166 9978096691486311966 5694373056023755415 7815690096691826513 1103275933683839552 5895542891044134509 11894732487323444487 2505393836307639840 10093788754137760497 4707584458765376704 8307188898020086549 9376...

output:

15180522216256224578
9392124937659601223
3731090297266184457
4088700438599152597
12141047238741589627
13690831665706691537
6137001830770875119
7710540224612738933
1127395840873126729
2547428643630768226
11276243151896249930
17424485450812448884
7349818962346687887
5470805592498440155
175038017689994...

result:

ok 100000 lines

Test #9:

score: 0
Accepted
time: 430ms
memory: 285760kb

input:

500000 100000
7998967471673371582 10130114419746398664 3551104684935464564 16685912987850328972 15511627867796069361 14936250795135295380 4459893621649123553 231042979002434189 12012936660604067430 2904992764724124790 11143303174224955423 14451025218833269546 1754517928855676235 7134560987488737406 ...

output:

1110650069515649932
5912382191329152172
621049367733791305
16761108311614751314
15914665672331903790
14220790622677061421
5631638233891908584
7684804426465509033
14144814832404731330
16097253704711336991
2968280359984267989
5346852515106429646
3425570440230240081
2224629419443001294
1831513998879473...

result:

ok 100000 lines

Subtask #3:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #10:

score: 0
Wrong Answer
time: 842ms
memory: 285756kb

input:

500000 100000
200191340929944401 12656615506596552505 16633050881913566440 11502837812276521947 10790959349780699890 16488127686621042658 4109113967985622378 17555775201632271905 1290245304295682315 7179623333690333199 15269467703158069058 941138697396034626 8224500868035537418 7455271978400711386 1...

output:

758501887551594031
1665604119059722056
11191595722589800009
16036118348547035544
3311299231376007948
3165761541860967523
15741513255298149248
8552503196413199552
18249642591896749704
5552959291540747102
11901219796103030004
12953232369971233848
13846187965276168594
4894964790582299479
93275308798495...

result:

wrong answer 3rd lines differ - expected: '403038032845801033', found: '11191595722589800009'

Subtask #4:

score: 10
Accepted

Test #15:

score: 10
Accepted
time: 766ms
memory: 74320kb

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: 766ms
memory: 74612kb

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: 773ms
memory: 75564kb

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: 750ms
memory: 75660kb

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: 771ms
memory: 73928kb

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: 772ms
memory: 76352kb

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: 758ms
memory: 78212kb

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%