QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#9727#1005. 子集卷积RainAir#100 ✓835ms126584kbC++111.4kb2021-04-09 19:11:242021-12-19 11:43:32

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2021-12-19 11:43:32]
  • Judged
  • Verdict: 100
  • Time: 835ms
  • Memory: 126584kb
  • [2021-04-09 19:11:24]
  • Submitted

answer

#include <bits/stdc++.h>

#define fi first
#define se second
#define DB double
#define U unsigned
#define P std::pair
#define LL long long
#define LD long double
#define pb emplace_back
#define MP std::make_pair
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 19;
const int ha = 998244353;

inline void add(int &x,int y){
    x += y-ha;x += x>>31&ha;
}

int f[MAXN+1][(1<<MAXN)+3],g[MAXN+1][(1<<MAXN)+3],h[MAXN+1][(1<<MAXN)+3];
int n,N;

inline void FWT(int f[]){
    FOR(i,0,n-1){
        FOR(S,0,(1<<n)-1){
            if((S>>i)&1) add(f[S],f[S^(1<<i)]);
        }
    }
}

inline void IFWT(int f[]){
    ROF(i,n-1,0){
        FOR(S,0,(1<<n)-1){
            if((S>>i)&1) add(f[S],ha-f[S^(1<<i)]);
        }
    }
}

int main(){
    scanf("%d",&n);N = (1<<n);
    FOR(i,0,N-1) scanf("%d",&f[__builtin_popcount(i)][i]);
    FOR(i,0,N-1) scanf("%d",&g[__builtin_popcount(i)][i]);
    FOR(i,0,n) FWT(f[i]),FWT(g[i]);
    FOR(i,0,n){
        FOR(j,0,n-i){
            FOR(k,0,N-1) add(h[i+j][k],1ll*f[i][k]*g[j][k]%ha);
        }
    }
//    FOR(i,0,n) DEBUG(h[i][N-1]);
    FOR(i,0,n) IFWT(h[i]);
    FOR(i,0,N-1) printf("%d ",h[__builtin_popcount(i)][i]);puts("");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 796ms
memory: 126580kb

input:

19
295104934 111814468 679703962 350815157 661791526 865051281 43411341 207358363 75519908 681336618 871711375 681249213 550559707 662716097 856748369 128340305 993619969 738085679 125994416 970719360 242257007 969140579 624833116 69896915 245857309 106508450 627920018 249585598 45102411 468567376 148898817 113243827 995359863 683925132 410507667 65921496 103806932 28476003 865388609 731236827 596511193 764081717 333550387 860293067 753407093 31088106 427733563 483232613 511126693 355215029 9446...

output:

666717557 375292648 882589615 357691302 956468061 181647548 725684410 746064946 751228098 697047097 880278834 727505077 661978757 955300919 758122803 903302079 950897700 783956747 202299054 38906838 758184337 688493822 798190100 738262989 373637279 501187194 313818972 500614170 22583095 254600040 815928905 96691317 307240356 612149600 713124832 448678140 847344006 49319863 208607094 705317788 857058919 845841981 580786763 529172642 209636389 607005465 718260062 815911893 581631734 989401228 5348...

result:

ok 524288 numbers

Test #2:

score: 0
Accepted
time: 835ms
memory: 126584kb

input:

19
367249149 371654773 612806524 85143906 444570010 814260143 268911024 159227014 54487563 176577835 890074755 614147905 745861895 131560065 544527098 62973049 231942232 691473827 751529607 880993263 98927562 537178388 988998270 879035753 229049001 546651320 497435301 767033665 579462410 226404362 577984034 203714308 543970869 469980641 896115544 329375756 745057818 839321413 317874102 134871440 543889158 156681921 158223532 27774342 492791907 237834244 40373768 781058979 767303780 671662953 643...

output:

911142043 248183662 71879437 742118276 961480169 806213174 13891593 637072967 404336157 897594321 986917648 472559245 243389874 518388575 570716943 20461212 214047179 918129003 52491516 881194031 74935008 302737295 82747481 187298711 417081789 700811862 468708204 835411352 133728419 280445753 468005494 981694558 2702524 232899411 50259520 278182258 677981247 252193752 612642198 78908336 483368129 819486254 505315277 207123268 626133374 450840047 69031559 411461957 763878507 103298433 183295237 4...

result:

ok 524288 numbers

Test #3:

score: 0
Accepted
time: 762ms
memory: 126532kb

input:

19
615932645 190043372 535430605 181906837 432498072 413679442 29566740 593061812 488985574 81150900 133120341 801471628 431152426 142547759 448741721 921999626 444025656 850597639 714476646 645838601 340534130 109590898 20701051 985172017 826859167 990919147 99631265 351023843 196254255 512822721 876810280 874335839 935713691 31829694 895431710 743712901 969261200 145967107 7444200 976101644 57709227 874366975 870152372 723269305 828731102 968847186 325728732 797114112 872214221 546779290 40564...

output:

798524062 836708584 11411000 610719566 821627279 424932369 655853799 232647098 793474357 624381502 814438974 359714448 488446738 70477305 273132533 127342891 583872767 56779627 901037664 608474084 950983738 856481429 500010299 932373283 909394121 304336341 56901825 374142368 359527086 106388193 486178033 530298343 461796812 995296332 868876618 755317797 761674426 500448861 932898419 943288860 260692582 983370177 124737769 535717840 411309963 527155765 520665161 700169456 169958836 547734937 9929...

result:

ok 524288 numbers

Test #4:

score: 0
Accepted
time: 807ms
memory: 126580kb

input:

19
245817417 883778526 432488758 755021884 492424307 52947991 431778541 893408310 329690521 612440312 741654491 524157501 281124503 352705877 417063083 604454041 7083290 954525811 217706893 654073991 448153193 505332760 403115212 596170631 251500337 178830251 782999157 98954798 378314111 589289447 900770590 798465354 330891140 277092012 326828368 544639808 647989213 116745295 451400515 456934846 452811220 397602790 7806269 239060799 977268168 175668256 147888169 988665568 810792473 888634369 970...

output:

925715523 463396036 253122336 746247174 221952149 512565300 611066319 821263570 902287784 287411386 308151351 205515705 554141360 778108572 974573600 144817013 939149492 286317698 557454987 545029287 134439650 117247639 84955015 853651918 490397108 1321272 319429345 514875499 562207064 426929780 62558750 904999557 329881273 592839100 107093700 475295050 571330744 98114118 757100778 279037786 590896499 470521339 146786989 439604211 485118243 760926938 924881498 684012105 819546845 671939487 52285...

result:

ok 524288 numbers

Test #5:

score: 0
Accepted
time: 788ms
memory: 126552kb

input:

19
222442934 511361881 729631014 497536732 15815890 613229253 526581872 228663305 628368339 871732877 716973286 500910086 153070676 698840833 149263258 3796944 776012857 586365263 106501498 232682928 355438618 168825846 600679155 821769479 675801894 632014633 325220619 364753565 57460713 67701605 726457420 68999442 877415910 340755952 43047416 874493729 634568307 684310140 121640482 840177595 980472502 988282356 264522598 224778395 88739882 917350813 234419634 863026979 836575373 242944883 69412...

output:

263543398 554294060 75268361 182521598 410607509 683272878 516520538 358521099 131126575 81699184 491594980 976469262 657193785 78279772 858961357 330065663 636985422 196845155 864690804 824944812 167791801 287738061 831257179 586790508 927241579 327648132 435981447 770939106 76203884 528027270 628234109 503745946 94560664 202918691 416223576 981986889 236865970 327680720 825382966 240139660 419989896 448221219 281081393 108276421 526498196 738546579 811529266 708724034 324384651 316237034 61740...

result:

ok 524288 numbers

Test #6:

score: 0
Accepted
time: 802ms
memory: 126512kb

input:

19
982245465 678815919 172958750 498875901 602207465 691745393 929365263 871283007 791476485 834232069 253899427 516528849 146554575 468222411 856822961 743464859 671216538 962486616 777527902 296922236 717800048 577506555 392923028 853962478 528952724 679640374 438099253 32184937 179397659 880305047 533393727 786087547 937699802 42651807 661153827 702206784 281380749 481216796 768458035 177941061 145304694 471278057 890339626 24531985 170846162 974156045 827922969 443413972 499422147 698229430 ...

output:

810764882 578933086 543472060 572085649 144510603 385360072 806919436 384263614 179541572 416483376 751052377 707446519 423086649 979387331 336464072 578844005 841096527 316069412 34013586 133423663 777493998 843996707 277243347 62346963 867237256 116350436 754717143 244201317 952285562 571617090 71332608 444598433 887287431 475041166 3920050 158206988 303728765 66552544 297445850 324409646 341813445 89165643 417536414 44089616 631864290 683734641 491871910 281703508 180171526 904754743 14765714...

result:

ok 524288 numbers

Test #7:

score: 0
Accepted
time: 773ms
memory: 126584kb

input:

19
934508222 260755822 3524299 151721777 142063333 872188319 623570321 964581305 803430317 246074142 316072350 836947498 590669680 7885046 245723680 640998417 633892017 445601214 293326755 827896644 175644664 327499978 471426780 961594269 292028675 842790900 539142353 315509858 713750057 945952173 637793636 342119912 5895152 943303689 707041899 647279864 904327186 584917322 767177875 731117836 724288024 843474140 941610093 573361298 346152189 623441707 391306043 253752208 143409207 103966628 641...

output:

48194334 900447933 679266151 885506027 207529011 394620893 10164736 555815552 361665940 125676657 162958644 204992381 876607170 879710069 471545257 458618045 491953862 537399512 919984618 535823821 743245956 817593986 181282112 750180006 220336903 844003501 351305050 637047503 822074137 241848190 463998762 35892291 206458755 750810012 16506028 675913139 160197222 969038932 172859626 569556674 922105826 557766756 390155077 703148533 356092053 220475699 83764408 471250400 868719800 28847429 628945...

result:

ok 524288 numbers

Test #8:

score: 0
Accepted
time: 821ms
memory: 126572kb

input:

19
46801055 613215314 305240996 750409146 262853019 398577491 446698060 104929123 421751826 736235182 610663552 983957423 989867018 644201263 961288295 84307524 514175191 822546656 52322975 314816436 2701910 148390555 467825444 936502279 793664514 869188642 313585466 226426540 628882505 122217250 374527139 834036738 934854621 410661388 520344519 984749956 785632586 485653097 699433730 464919898 911641286 551397311 342902314 344568501 652979566 323454837 929382666 923107073 967865186 7015473 4658...

output:

824362594 465915290 912962712 190820933 52532657 470269427 142908917 201974871 404430544 518799957 62674408 314866426 143198501 408206385 828577782 759468832 840539448 213674026 696214888 225780684 625833503 742551219 413416408 607477562 13795105 204681784 838471403 551237637 730876333 598967471 444553434 616550846 525872622 175457989 326981380 876796843 378235147 373240136 788802625 420160722 322564979 225418780 634674071 773348942 962182227 19902079 969096992 220359808 194170975 416200196 6893...

result:

ok 524288 numbers

Test #9:

score: 0
Accepted
time: 814ms
memory: 126584kb

input:

19
250153981 582575310 44878323 292191195 506329440 801231842 170499669 976141540 213796831 645510659 291273604 848779769 663441878 212414309 701496649 184902147 657021163 951776358 976601588 499383637 315196460 575259820 923916008 589050926 799455907 408661277 101924263 965992475 51641616 254359788 872142273 115742061 908067953 995018103 414541954 650762900 893123956 232235761 130013281 663443658 205680427 5837019 809016414 519275431 775641542 304257830 155137753 471541989 637781767 939314888 8...

output:

829157265 283660975 202484620 752931196 748529299 771211480 373213058 117759458 350677948 303658908 171801260 988253047 344927824 613152758 479954516 264498973 27229660 517656912 638230667 131024292 525326774 778119748 333110250 743293560 205876626 935518761 978245409 311081547 634856571 154407433 821660131 481480455 585620233 538703965 939061965 624422194 972208281 592076815 969973711 618447966 139531130 210092097 480275558 10501200 147948859 467917705 497642424 523321175 443987204 580029410 81...

result:

ok 524288 numbers

Test #10:

score: 0
Accepted
time: 806ms
memory: 126576kb

input:

19
415466891 595464312 122206640 601450584 60514242 66667614 734636982 307907841 275892141 804916803 367904061 885408918 917217487 31521306 774952123 63403999 844256072 778305913 558237134 482228608 224823338 811589615 554979379 90852860 637997152 938642239 403976153 468893520 666088689 421572577 30749913 788543087 175162890 556718959 893170726 271032652 96380863 867901257 583284812 770097170 858033561 157060510 836267829 949389540 66613415 541912276 286686820 562744372 239406878 792833298 75704...

output:

53788882 629886811 87708407 493557566 825379173 477864620 503163123 750876731 943144563 411402881 450863727 587764002 595396313 541606359 920842076 130600921 591143326 481908500 345865936 602836982 332235812 926640713 827955399 510584984 918632480 292514147 395659129 322618659 740086124 613809597 284283533 43587817 271406103 953007062 226871091 872856037 431554902 44609483 142783263 345398891 521070615 9630638 710650604 117769742 933854301 763955772 870284262 873791285 535978563 725108300 253370...

result:

ok 524288 numbers