QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#823196#4283. Power of XORLuluWA 1230ms106336kbC++142.9kb2024-12-20 20:22:282024-12-20 20:22:29

Judging History

This is the latest submission verdict.

  • [2024-12-20 20:22:29]
  • Judged
  • Verdict: WA
  • Time: 1230ms
  • Memory: 106336kb
  • [2024-12-20 20:22:28]
  • Submitted

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=44;
const ll mod=1e9+7;
#define lowbit(i) (i&(-i))
namespace L_B{
    ll f[N];
    void insert(ll x){
        for(int i=N-1;~i;i--){
            if(x&(1ll<<i)){
                if(f[i]){
                    x^=f[i];
                }else{
                    f[i]=x;
                    break;
                }
            }
        }
    }
    int getsize(){
        int res=0;
        for(int i=0;i<N;i++){
            if(f[i]){
                ++res;
            }
        }
        return res;
    }
    void rebuild(){
        for(int i=0;i<N;i++){
            if(!f[i]){
                continue;
            }
            for(int j=i-1;~j;j--){
                if((f[i]&(1ll<<j))&&f[j]){
                    f[i]^=f[j];
                }
            }
        }
    }
}
using namespace L_B;
int popcount(ll x){
    int res=0;
    while(x){
        x-=lowbit(x);
        ++res;
    }
    return res;
}
ll qpow(ll b,ll p){
    if(!p){
        return 1;
    }
    if(!b){
        return 0;
    }
    ll res=qpow(b,p/2);
    res=res*res%mod;
    if(p&1){
        res=res*b%mod;
    }
    return res;
}
int n,m;ll k;
ll a[N],g[N+1];
void init(){
    for(int i=0;i<=N;i++){
        g[i]=qpow(i,k);
    }
}
ll solve1(){
    int p=0;
    for(int i=0;i<N;i++){
        if(f[i]){
            a[p++]=f[i];
        }
    }
    ll res=0;
    for(int S=0;S<1<<p;S++){
        ll val=0;
        for(int i=0;i<p;i++){
            if(S&(1<<i)){
                val^=a[i];
            }
        }
        res+=g[popcount(val)];
        res%=mod;
    }
    return res;
}
ll dp[N][1<<20];
ll solve2(){
    for(int i=0;i<N;i++){
        if(!f[i]){
            continue;
        }
        int p=0;
        for(int j=0;j<N;j++){
            if(f[j]){
                continue;
            }
            if(f[i]&(1ll<<j)){
                a[i]^=1<<p;
            }
            ++p;
        }
    }
    int sum=0;
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        if(!f[i]){
            continue;
        }
        for(int j=sum;~j;j--){
            for(int S=0;S<1<<(N-m);S++){
                dp[j+1][S^a[i]]+=dp[j][S];
                dp[j+1][S^a[i]]%=mod;
            }
        }
        ++sum;
    }
    ll res=0;
    for(int i=0;i<=m;i++){
        for(int S=0;S<1<<(N-m);S++){
            res+=dp[i][S]*g[i+popcount(S)];
            res%=mod;
        }
    }
    return res;
}
int main(){
    scanf("%d%lld",&n,&k);
    init();
    for(int i=1;i<=n;i++){
        ll x;
        scanf("%lld",&x);
        insert(x);
    }
    m=getsize();
    rebuild();
    ll res=0;
    if(m<=24){
        res=solve1();
    }else{
        res=solve2();
    }
    for(int i=m+1;i<=n;i++){
        res*=2;
        res%=mod;
    }
    printf("%lld\n",res);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3848kb

input:

3 2
1 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

2 1000000000
1 2

output:

140625003

result:

ok 1 number(s): "140625003"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

3 4
21 31 15

output:

1076

result:

ok 1 number(s): "1076"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

4 10
21 16 23 30

output:

3504120

result:

ok 1 number(s): "3504120"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

5 795325759
23 18 18 15 24

output:

398580583

result:

ok 1 number(s): "398580583"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

6 425010546
15190825693299 11021868218180 10853490476696 16489831131502 15731786397897 1859285400474

output:

226806798

result:

ok 1 number(s): "226806798"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

7 376524109
14035202899482 10047025581205 744778190838 10085364176616 17517303536898 10648638998430 4344258259221

output:

909089159

result:

ok 1 number(s): "909089159"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

8 849112677
12651182249229 2557626671152 16190796268614 7679451552477 1419165382365 16010747922241 1877804892046 6782866140038

output:

60890703

result:

ok 1 number(s): "60890703"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

9 874735099
10148022499611 4300816040299 6425463859799 11220407430827 16167481816769 5361425691648 9036180330515 1461806017525 5752555300268

output:

371891946

result:

ok 1 number(s): "371891946"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

10 466547903
14475814446599 10414899512095 8279261110485 15402964537241 12059977291235 14960757658011 15642794803423 176456760404 8544855584093 939455648117

output:

705005476

result:

ok 1 number(s): "705005476"

Test #11:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

11 587282176
2381973819369 7896756717881 3605049079058 3476202500557 8161539414084 4107261754597 4052905214220 13489145138694 14249896320133 4915388559035 946556082447

output:

221771132

result:

ok 1 number(s): "221771132"

Test #12:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

12 416671000
12040275816251 17062751464343 7135252213488 464175530141 1680797265108 8088672081270 15974373338891 2807308701611 10474875618229 14385428199760 7217460885705 14772837072591

output:

888526388

result:

ok 1 number(s): "888526388"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3904kb

input:

13 555186260
16812780767710 10577402574202 14435021461484 7629604678144 2685467464476 6345623360274 243420234591 10035113157523 3422776077242 10218637237089 14851966122299 403170012001 9905420122107

output:

990043010

result:

ok 1 number(s): "990043010"

Test #14:

score: 0
Accepted
time: 2ms
memory: 3912kb

input:

14 509328299
8353561750434 10104176798819 6443583453798 16526745760567 11644429218948 7613211796505 14675590153019 16014035780673 8977332980184 8018462423140 10321575146167 3765866187251 951943560884 16567591980900

output:

554786244

result:

ok 1 number(s): "554786244"

Test #15:

score: 0
Accepted
time: 3ms
memory: 3776kb

input:

15 608613602
13478763858236 3740903255952 1077573334827 10777446313857 9164622625061 3532139720401 10581691792868 227725402800 1100326438302 11314744041629 5716533742148 13171916589439 3380813371904 4280184438172 3241608634862

output:

451055479

result:

ok 1 number(s): "451055479"

Test #16:

score: 0
Accepted
time: 5ms
memory: 3848kb

input:

16 940201087
10256426323317 3262426443677 11042930351118 9509672586143 6874576733055 17425354233945 44840572217 271060611230 5160013582892 940549858628 3460145241956 1911512043119 6262508016313 15998335209279 4331486722244 1174379722227

output:

609521624

result:

ok 1 number(s): "609521624"

Test #17:

score: 0
Accepted
time: 9ms
memory: 3772kb

input:

17 224938820
17119676032384 14016470814638 9555327895162 4956367760197 14164877522334 11840938437493 196922732084 1117964651219 15662255500985 6799149377748 2081570899516 8101318468846 6806038800783 8481897921532 14327689591834 3468429675406 707483765694

output:

952629882

result:

ok 1 number(s): "952629882"

Test #18:

score: 0
Accepted
time: 18ms
memory: 3840kb

input:

18 572144592
1034330548675 7466761131151 5479486866730 5805192559012 2072047969997 14094135393106 3957442001455 9636000453501 6359658906102 13786563194342 12655202300227 17497546480004 15210614567784 5757118085432 3507806179905 4092815624732 2831474245754 8905127237409

output:

711094061

result:

ok 1 number(s): "711094061"

Test #19:

score: 0
Accepted
time: 38ms
memory: 3788kb

input:

19 655059034
10160251337230 17368680333349 7582672215712 15170782424265 11091464398448 3468569802147 12985801017272 11885768849226 2042891901510 5816113601266 17200614913667 3230577285683 6122037312518 4476865090037 17458280591698 8087876238641 12295868407218 14891985681505 9046310739642

output:

444845559

result:

ok 1 number(s): "444845559"

Test #20:

score: 0
Accepted
time: 74ms
memory: 3836kb

input:

20 230956009
5657766305333 6062575310370 15139059764699 15999531683504 8700249448570 8496370986569 11931362029342 16808274736949 6582914043608 3148217142903 623248093777 2603754608083 16741237934194 11551777078922 17177864498497 147568049427 2693939410255 11977553059228 14614351055705 11790115139758

output:

618103113

result:

ok 1 number(s): "618103113"

Test #21:

score: 0
Accepted
time: 149ms
memory: 3840kb

input:

21 991001581
13505588614813 8588095735948 6076766289787 11667017057163 7602334689492 3100571431902 16456031754497 17012042226760 2298783364823 2292586959243 16484353107729 6379611127333 2309984518512 17222120007066 15742378844056 10137340715213 11581793910964 6058313717190 9891627922923 939856806688...

output:

340865032

result:

ok 1 number(s): "340865032"

Test #22:

score: 0
Accepted
time: 301ms
memory: 3840kb

input:

22 793915239
14683316686425 5162188247000 7429819452817 16611661938749 11084135813793 13856133740403 13108004035448 13856666274966 9461726048738 5612503807810 15177562338647 5006352927897 15216557346760 8527880141821 15843683785466 7692179013817 127553824751 5234432790248 6453714209319 1152804933059...

output:

669154856

result:

ok 1 number(s): "669154856"

Test #23:

score: 0
Accepted
time: 609ms
memory: 3724kb

input:

23 46024280
7514210736994 16544433148860 5457306548546 5030077832970 10322997084235 5669909500374 8381456993928 10988407597025 8111544042162 10588037243918 12116378947678 13379626855924 10216405913667 9728737199159 12487637411090 11957321472850 15722206258699 17236861929685 15970454160165 2302405750...

output:

560027727

result:

ok 1 number(s): "560027727"

Test #24:

score: 0
Accepted
time: 1230ms
memory: 3844kb

input:

24 987331368
17225443429613 10254751679227 3710337795354 9960878278886 3536301339395 8181058117864 15108863858942 3302198449417 6902193486641 8347347537914 8639500195933 3284177408604 9417624777639 5862512932466 10643916118422 14918257011693 8684158391259 10231904191169 17423403571877 13578583210490...

output:

902893141

result:

ok 1 number(s): "902893141"

Test #25:

score: 0
Accepted
time: 418ms
memory: 106336kb

input:

25 6356342
633691957112 12691686740693 2837615772764 12061807109950 14923133272874 14814883481961 15999555715426 13555874031521 6459210859425 556162071453 8417793517180 3701478570933 2799170553419 4135575419616 8116459391381 584184726086 12797443971069 16036119552969 1578981557574 7989957867379 1096...

output:

314404834

result:

ok 1 number(s): "314404834"

Test #26:

score: 0
Accepted
time: 200ms
memory: 57132kb

input:

26 928302018
15796444138481 11937355225779 6149665857421 3432433989770 2307410764687 17243936548925 6178469381919 8828731666077 3415993426130 1036426554693 14386104368478 13448264214939 12599370135462 16273290761628 7852195291114 16757484794229 2980400729227 11047051074570 5685198104638 421391190008...

output:

591376981

result:

ok 1 number(s): "591376981"

Test #27:

score: 0
Accepted
time: 102ms
memory: 31600kb

input:

27 480419745
4145596348089 13831737653400 9545784734814 7089337349957 9243766525372 1698760550338 8314204232940 17135513984234 5360266298682 693379386669 7453920000573 3379010454561 9496461189551 12453833354267 15745056540568 17109612762746 10622937495285 1165619220427 14117496847220 1823672971704 4...

output:

996372291

result:

ok 1 number(s): "996372291"

Test #28:

score: 0
Accepted
time: 59ms
memory: 18184kb

input:

28 27620780
4204096460478 8700358786074 628759280540 15819632141706 11528168860397 2047602918598 2208936905680 16844201430119 4922560201264 11042766599853 6076732267197 13388956542677 9004635452128 3349421622867 12810902457534 219019419498 6546649793965 11747065726619 2731914339282 13136226835257 13...

output:

348395771

result:

ok 1 number(s): "348395771"

Test #29:

score: 0
Accepted
time: 18ms
memory: 11312kb

input:

29 347892581
15006126486888 11001925766091 9257216536100 6133874519974 2687454633406 15845589829065 3805013411660 5263511938621 3299649580709 16563565591632 13955136271077 2229147702962 3498920831578 63854880067 14415057323130 1090256639310 3243485652885 16180748119689 11578998566861 15966269694598 ...

output:

611108570

result:

ok 1 number(s): "611108570"

Test #30:

score: 0
Accepted
time: 17ms
memory: 7804kb

input:

30 542105640
10676361007128 11271820870201 718962729015 2660619621103 10190643847665 1262003135580 7792833542395 11868162027516 16743297711622 6429765075728 1883703256098 13842531695072 7879707445110 12437371248883 4757697833595 8206172462252 10683253157445 15764136545580 4331987796420 1491658514684...

output:

593090324

result:

ok 1 number(s): "593090324"

Test #31:

score: 0
Accepted
time: 9ms
memory: 5836kb

input:

31 420929238
4353544661234 13587991203358 14418855720932 8080674455188 15668100023944 2917121454675 5138020726910 10506297685379 4906702461075 14201428040874 10206172453759 224469740630 3134975585033 14250295114337 15285589705101 13797618432844 2682476836468 923998938496 1646631023625 16428851144297...

output:

863450526

result:

ok 1 number(s): "863450526"

Test #32:

score: 0
Accepted
time: 0ms
memory: 4936kb

input:

32 605825016
14732385106335 10342785380400 14366530169701 3372216146888 7693545284667 16271781174612 5615189072200 17307807257155 17396283620946 17387749828902 11896532394227 4759569795785 2012677833047 3820785889232 4026103672304 15541491978700 2660638755667 11380858077351 2946794283633 16401494963...

output:

940579820

result:

ok 1 number(s): "940579820"

Test #33:

score: 0
Accepted
time: 3ms
memory: 4504kb

input:

33 61333334
13349672208641 11462530201432 11221829296831 12564233577813 5733005483896 8291461447149 6489196859327 11607861547061 3347821211207 825735302798 13465784197103 42085792299 15424003069425 251947882904 9397856499895 11904087866162 1421502725377 908916957220 5299645280854 15713747851652 1979...

output:

600255829

result:

ok 1 number(s): "600255829"

Test #34:

score: 0
Accepted
time: 0ms
memory: 4324kb

input:

34 29634340
4593539746942 12664851273233 14584817448823 1136569495526 9654423245379 14537332349027 11591915205386 2150710023371 7325095874862 1077716335653 537889693154 1214240914334 15236338636223 15007466363260 17038783879742 5492896253242 13540362995342 6001134284263 9260665584749 6776895776889 5...

output:

658476748

result:

ok 1 number(s): "658476748"

Test #35:

score: 0
Accepted
time: 1ms
memory: 4104kb

input:

35 955095333
10664815126398 2520862347714 8942866821632 15577096895032 10813875704208 7096756961336 10255695927486 6016365432437 7275378606171 13453436913416 10997146184365 16854614338355 9663888095682 12614260899375 3133867374556 16182169038584 8347883153141 13734469085938 1769501149796 10551103508...

output:

504281440

result:

ok 1 number(s): "504281440"

Test #36:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

36 326011318
2314891961818 27531577360 5482814944280 10792300324312 3438950898784 11782271760580 8489382585972 8375921060954 1540239851725 15173256669049 2031799206478 11671308298556 9927608017307 11542671493274 15020474648945 14639131579795 14402551797206 12619833018276 8993166590456 16372480811097...

output:

23530344

result:

ok 1 number(s): "23530344"

Test #37:

score: 0
Accepted
time: 1ms
memory: 3972kb

input:

37 855755785
12916500661980 7260557493349 1426783475387 5692320966663 10913493997683 4848914456607 12231707353353 9776938412855 15999920343290 14855687803332 16118760621563 2208348379137 10112748149029 17405168033863 14406986633718 4647957185424 6086227450820 13147912747388 10770034182129 8577796168...

output:

895453730

result:

ok 1 number(s): "895453730"

Test #38:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

38 123723770
868222898854 12385100039427 16358520414413 3789768565075 14864690227172 9153161952993 9343490982396 10756599289467 1116543654761 2769028977410 9982596884588 4486500890180 2880703448840 1521103263877 16216691892080 16626759859045 10761746485626 5720397078356 9374387841846 2213735681499 5...

output:

538679438

result:

ok 1 number(s): "538679438"

Test #39:

score: 0
Accepted
time: 1ms
memory: 4004kb

input:

39 140633454
5850731569372 17342061556757 3862182114292 13675830714366 3364826946285 4969362607203 2560550114189 6025382131087 16093815244018 4937431614184 17195713158177 141578596745 7201254943395 6282797227910 1960499086282 7433844119508 6843589289719 14230442485946 11115358855709 13379325973066 1...

output:

591428190

result:

ok 1 number(s): "591428190"

Test #40:

score: 0
Accepted
time: 1ms
memory: 3980kb

input:

40 27942099
1232341868314 5178658983438 13541012046993 5729882896808 9808295881289 10084612826618 14674276067281 16759377603968 9934549682045 301845966060 9972593979073 11445294088919 6472106316658 6440504148827 6634571702645 11471875971397 5161969372568 10948870779506 16917406833450 15847147407597 ...

output:

778362530

result:

ok 1 number(s): "778362530"

Test #41:

score: 0
Accepted
time: 0ms
memory: 3988kb

input:

41 789816771
2879432886185 634764983271 5017579226048 8911795438300 7768489935497 9477516310951 6401708922227 15717147427600 16385806977053 14712806485166 12762198115407 7944194970410 16905013920496 15068825417286 8100699468324 13224295366473 16821533426836 11196396697334 5371796834966 316573434578 ...

output:

174260590

result:

ok 1 number(s): "174260590"

Test #42:

score: 0
Accepted
time: 1ms
memory: 4056kb

input:

42 175202370
3688404515611 12267967281472 3234388825492 9927936690407 15002542212598 3356238313848 14628729631800 2114483946084 9805644059268 9140480316827 13627795085464 1206133863726 15273201972631 15317083820880 17179563434672 12832243229924 8876742889236 6171718990914 9846450712061 6231412223204...

output:

494770210

result:

ok 1 number(s): "494770210"

Test #43:

score: 0
Accepted
time: 1ms
memory: 4012kb

input:

43 610245847
9719798801202 12640523217311 2908176462165 5888239951766 7514239857874 7051856596375 7841512925710 9921449746502 6941029486813 8834577315284 9309025405416 13350828298387 5493129721564 9378024478637 13164780009926 4124504313309 16291183136514 10744631147261 4245121464572 16291181131364 2...

output:

314807576

result:

ok 1 number(s): "314807576"

Test #44:

score: 0
Accepted
time: 1ms
memory: 4080kb

input:

44 398159970
13986446665254 9075168617884 15899959330301 3022101112229 12724552902601 4753430845256 12653243596000 15794124500009 3295715613006 10351691462439 11163729902156 9365739035504 17189492655425 10513977547797 12412448014601 11757657166816 9412817167607 10750107042210 7902311392811 149245407...

output:

605976287

result:

ok 1 number(s): "605976287"

Test #45:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

44 610914205
8439854970113 13248568970903 14623020801401 2316814766191 3205672125504 10078115178899 7539695456046 12484204154475 13497460825260 7835114086337 11698023887562 6762333068746 7011150426790 12840842404583 13562207314854 6027965940863 4782566751384 315850736838 8656432700800 1483921364076 ...

output:

688535325

result:

ok 1 number(s): "688535325"

Test #46:

score: -100
Wrong Answer
time: 1ms
memory: 4080kb

input:

44 289861763
518064177219 7829863898727 7156512612331 5089005930430 12190195912494 16688462752330 15563676710591 5540321450298 12211453998357 5365715120634 17008568654212 1143977836937 16761020085341 8678876567128 4679162507909 1130652325513 13262441371084 4103103219979 3101414683648 14733063270244 ...

output:

298282042

result:

wrong answer 1st numbers differ - expected: '298282041', found: '298282042'