QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342267#1003. 快速 AND 卷积A_programmer#0 27ms10476kbC++172.1kb2024-03-01 10:13:392024-03-01 10:13:39

Judging History

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

  • [2024-03-01 10:13:39]
  • 评测
  • 测评结果:0
  • 用时:27ms
  • 内存:10476kb
  • [2024-03-01 10:13:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 3e5 + 5;
const ll mod = 998244353;

int n, m;
ll A[maxn], B[maxn], C[maxn];

void FWT(ll *p, int typ, bool Fl)
{
    if (typ == 0)
    {
        for (int i = 1; i < m; i <<= 1)
            for (int j = 0; j < m; j++)
                if (i & j)
                {
                    if (Fl) p[j] += p[j ^ i], p[j] = p[j] >= mod ? p[j] - mod : p[j];
                    else p[j] -= p[j ^ i], p[j] = p[j] < 0 ? p[j] + mod : p[j];
                }
    }
    else if (typ == 1)
    {
        for (int i = 1; i < m; i <<= 1)
            for (int j = 0; j < m; j++)
                if (i & j)
                {
                    if (Fl) p[j] -= p[j ^ i], p[j] = p[j] < 0 ? p[j] + mod : p[j];
                    else p[j] += p[j ^ i], p[j] = p[j] >= mod ? p[j] - mod : p[j];
                }
    }
    else if (typ == 2)
    {
        for (int i = 1; i < m; i <<= 1)
            for (int j = 0; j < m; j++)
                if (i & j)
                {
                    if (Fl)
                    {
                        ll X = p[j ^ i], Y = p[j];
                        p[j ^ i] = X + Y >= mod ? X + Y - mod : X + Y;
                        p[j] = X < Y ? X - Y + mod : X - Y;
                    }
                    else
                    {
                        ll X = p[j ^ i], Y = p[j];
                        p[j ^ i] = (X + Y) & 1 ? (X + Y + mod) >> 1 : (X + Y) >> 1;
                        if (p[j ^ i] >= mod) p[j ^ i] -= mod;
                        p[j] = (X - Y) & 1 ? (X - Y + mod) >> 1 : (X - Y) >> 1;
                        if (p[j] < 0) p[j] += mod;
                    }
                }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n, m = (1 << n);
    for (int i = 0; i < m; i++) cin >> A[i];
    for (int i = 0; i < m; i++) cin >> B[i];
    FWT(A, 1, 1); FWT(B, 1, 1);
    for (int i = 0; i < m; i++) C[i] = A[i] * B[i] % mod;
    FWT(C, 1, 0);
    for (int i = 0; i < m; i++) cout << C[i] << " ";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 20ms
memory: 10368kb

input:

17
42662 3827 76545 108831 25313 27266 67677 49044 32147 52358 110136 98785 109292 47880 104604 79427 21356 69205 91120 102276 66500 21270 57642 6392 16089 58759 83369 48885 44087 13580 32568 72525 50203 2175 32131 98566 104956 97622 122591 59620 130179 77529 90491 40080 17249 29852 124089 121649 11...

output:

566097218 487008967 893237583 289185225 252652351 994509971 141514869 553506246 430145955 909379664 408377244 443749780 179771519 839422604 600837303 965355139 150614577 592531530 346681649 665958032 255148540 598651994 456024825 942804976 174129042 95174453 995824094 854181395 73248414 913258107 71...

result:

wrong answer 1st numbers differ - expected: '187092', found: '566097218'

Test #2:

score: 0
Wrong Answer
time: 20ms
memory: 9276kb

input:

17
22855 107434 52803 90229 89505 80495 42180 9475 32330 74086 32412 21027 18538 15791 67485 59626 36435 121278 41301 7686 46310 63627 64081 75757 119351 53397 75140 46668 57425 106397 122163 119200 126128 114872 89333 109457 122327 123135 105915 12651 29868 67257 34126 62215 49248 27812 39497 24815...

output:

247565360 615945667 574322702 548237478 957427207 655311839 541154971 970781815 605009735 75961431 21507960 246058238 862184873 993639241 65488584 449787168 401896347 735254678 25913790 686701513 594974179 539989483 479607613 568868086 23192661 166664398 633391176 861943656 679737168 429269231 69445...

result:

wrong answer 1st numbers differ - expected: '783136516', found: '247565360'

Test #3:

score: 0
Wrong Answer
time: 24ms
memory: 8836kb

input:

17
70272 97050 8767 65864 32849 88052 94450 76546 28753 125164 104071 27376 108394 48523 92447 64823 83816 7335 96301 110066 90946 80030 69811 104000 26485 121439 88815 55834 65886 7589 19851 27739 79071 114263 59112 15156 16335 34678 48236 78364 58136 31664 51214 71751 20112 46330 75737 124398 8424...

output:

255065853 382434730 749313137 606994509 273248338 677907052 966727533 567203004 306303335 29520238 718366072 988103872 399453649 628585782 58065150 380043548 958310965 916653377 512548371 237358872 39136611 861970528 482094206 459378582 190247329 634374528 173709298 350622600 56628297 455275570 9658...

result:

wrong answer 1st numbers differ - expected: '652790520', found: '255065853'

Test #4:

score: 0
Wrong Answer
time: 24ms
memory: 8752kb

input:

17
37803 53349 7475 14815 37920 63423 130725 10105 98692 7060 112281 81068 119521 8493 102633 81243 103185 8430 126740 15149 11983 109796 55656 77806 84560 67646 81765 98052 43438 73472 20333 31261 129649 26861 77960 128528 15020 76695 92482 121232 119532 29122 97453 114257 8630 77944 85108 8439 127...

output:

782786721 880861834 74169467 476957113 792603957 474312519 274575894 75265963 839902748 510311236 755224966 377287148 175893378 676103398 455218975 618967023 687214283 279086287 590192764 651070234 598115269 64120464 538538627 639640971 605847965 737388747 287360946 28949957 248762072 392905869 4459...

result:

wrong answer 1st numbers differ - expected: '114888495', found: '782786721'

Test #5:

score: 0
Wrong Answer
time: 20ms
memory: 8696kb

input:

17
97311 126323 42986 21328 28294 63879 55749 106904 35083 12328 51989 122901 49683 90489 54771 7449 10577 3062 14365 42158 105598 102787 1697 53360 23897 105575 42515 69564 13588 116076 96290 46242 53478 77359 54419 124940 45908 41343 117697 53169 63073 70519 18594 49893 111926 109536 118152 63292 ...

output:

939965847 935643059 507394610 260047868 37553283 664061024 299578190 467335140 167076864 407103499 826684914 223399095 793984827 263692478 927440539 538859794 890719428 345178111 580712678 268888985 967629561 116050511 460256690 480824994 681475783 125032712 848319518 560622591 568783067 969951833 4...

result:

wrong answer 1st numbers differ - expected: '529778873', found: '939965847'

Test #6:

score: 0
Wrong Answer
time: 17ms
memory: 10476kb

input:

17
80920 106759 88886 68808 40681 129577 739 27081 3168 121135 40411 30502 115288 111815 12729 53417 91480 60238 127638 23069 22086 32285 67565 22414 103053 64282 124164 52161 37589 43113 40328 91740 77627 100006 31526 40265 34460 93412 76512 130221 44900 37645 14939 31417 101787 32864 129218 122519...

output:

873455235 578922740 663614863 446019662 270514059 179458516 163484255 383973264 445200917 931204984 891881509 226174253 370806163 182761886 136349947 816256124 491932995 576546371 519306286 778354763 995546997 164399033 782870823 664722952 612206022 487580144 885583842 296984560 264719763 380908218 ...

result:

wrong answer 1st numbers differ - expected: '76249871', found: '873455235'

Test #7:

score: 0
Wrong Answer
time: 27ms
memory: 9976kb

input:

17
92746 52367 67396 20863 36904 66952 110184 57034 119512 91601 22275 28480 24273 42747 69026 635 29433 110762 96317 112417 44986 95130 31329 114751 1223 68950 22358 72441 56173 58273 76910 73231 91465 15316 109444 53510 17654 109774 3115 106337 74182 50244 2818 67099 21782 107567 35483 69912 57620...

output:

134907120 724279004 939134626 188555153 27175141 698405406 574499266 666456558 614407244 56124664 155415866 840488190 655674719 947224126 323321654 570143474 395325207 907978614 862328293 982987769 265464537 851389294 358523878 237124193 478218612 309120576 54497605 408988553 384871234 586928460 866...

result:

wrong answer 1st numbers differ - expected: '423523969', found: '134907120'

Test #8:

score: 0
Wrong Answer
time: 24ms
memory: 10084kb

input:

17
42489 34768 108791 39505 26803 69959 95845 12195 25885 130634 19207 20008 64967 38342 66620 62352 22981 123439 114802 50748 57604 1819 51528 56182 85686 35342 46795 9693 97778 67171 110514 130843 103238 110683 24320 121990 23692 1897 88924 88112 123335 7597 129742 81828 117960 24979 125654 24240 ...

output:

551839345 77661851 371633391 771520966 54216681 588786372 962625760 823083402 14828046 344698532 79615952 707060387 754871465 28001941 862875557 311369435 307716718 739219904 238969867 157103184 384513823 310180470 596471332 82747769 655905576 165380347 973654740 347808170 107101704 95495679 5671924...

result:

wrong answer 1st numbers differ - expected: '296888965', found: '551839345'

Test #9:

score: 0
Wrong Answer
time: 24ms
memory: 8816kb

input:

17
58293 84783 21265 105799 100688 20012 66052 103897 100017 98468 15145 48464 115651 65170 19851 105184 87979 41301 71160 30495 54404 35802 841 12258 36078 82472 123485 105420 110358 9667 96588 100651 116587 118760 123273 32747 104384 110835 104588 51974 16465 6269 68737 91023 14587 77243 30454 811...

output:

191457484 686073957 78097251 743243355 67452109 207286689 905063133 81505576 501265225 855041676 135912061 265762623 175080495 715159506 527042741 991889641 511894937 817418640 985142525 493672209 252665856 766269047 851423387 475188241 215141516 68496307 355836 820233315 810125595 221361535 6757062...

result:

wrong answer 1st numbers differ - expected: '222512293', found: '191457484'

Test #10:

score: 0
Wrong Answer
time: 16ms
memory: 9288kb

input:

17
83312 18546 48178 122247 38198 20202 19089 40865 101246 4012 108757 8207 10878 29485 28297 106160 109473 129615 117399 124127 50255 64752 125828 75240 106637 6509 128707 10743 59094 39586 18699 12795 71928 18306 103082 108906 63706 94384 119133 105789 82038 11840 61569 72424 124668 83064 112905 7...

output:

136298463 992482182 937088892 189220513 866638270 835727250 779964199 627348473 273726705 893349658 402527417 315096552 601075287 67269660 392915920 563152650 419498373 99006814 874646182 239323202 992714075 195701252 648412894 512834640 507345238 612091718 465613474 144057192 782421609 722743734 35...

result:

wrong answer 1st numbers differ - expected: '674278798', found: '136298463'