QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758111#9120. Huge Segment TreecpismylifeOwOAC ✓119ms77060kbC++203.1kb2024-11-17 15:53:212024-11-17 15:53:21

Judging History

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

  • [2024-11-17 15:53:21]
  • 评测
  • 测评结果:AC
  • 用时:119ms
  • 内存:77060kb
  • [2024-11-17 15:53:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const long long mod = 998244353;
const int MaxN = 2e6 + 5;

int k;

void Inp()
{
    cin >> k;
}

long long Pow2[MaxN];
long long Fact[MaxN];
long long RevFact[MaxN];

long long C(int k, int n)
{
    if (k > n)
    {
        return 0;
    }
    return ((Fact[n] * RevFact[k]) % mod * RevFact[n - k]) % mod;
}

long long res[MaxN];
long long Dp1[MaxN];
long long Dp2[MaxN];

void Exc()
{
    Pow2[0] = Fact[0] = 1;
    for (int x = 1; x <= 4 * k; x++)
    {
        Pow2[x] = (Pow2[x - 1] * 2) % mod;
        Fact[x] = (Fact[x - 1] * x) % mod;
    }
    RevFact[1] = 1;
    for (int x = 2; x <= 4 * k; x++)
    {
        RevFact[x] = (mod - (mod / x) * RevFact[mod % x] % mod) % mod;
    }
    RevFact[0] = 1;
    for (int x = 1; x <= 4 * k; x++)
    {
        RevFact[x] = (RevFact[x - 1] * RevFact[x]) % mod;
    }
    cout << ((Pow2[k + 1] - 1) % mod + mod) % mod << " ";
    long long cur = 0;
    for (int x = 1; x < k; x++)
    {
        Dp1[2 * k - 2] = (Dp1[2 * k - 2] + C(2 * k - 2, 2 * x) * Pow2[k - x - 1] % mod) % mod;
        Dp1[2 * k - 3] = (Dp1[2 * k - 3] + C(2 * k - 3, 2 * x) * Pow2[k - x - 1] % mod) % mod;
        Dp2[2 * k - 2] = (Dp2[2 * k - 2] + C(2 * k - 2, 2 * x + 1) * Pow2[k - x - 1] % mod) % mod;
        Dp2[2 * k - 3] = (Dp2[2 * k - 3] + C(2 * k - 3, 2 * x + 1) * Pow2[k - x - 1] % mod) % mod;
    }
    res[2 * k - 2] = (res[2 * k - 2] + Dp1[2 * k - 2]) % mod;
    res[2 * k - 3] = (res[2 * k - 3] + Dp1[2 * k - 3]) % mod;
    for (int x = 2 * k - 4; x > 1; x--)
    {
        Dp1[x] = (Dp1[x + 2] * 2 % mod - C(x + 2, 2) * Pow2[k - 1] % mod + C(x + 2, 2 * k)) % mod;
        Dp1[x] = (Dp1[x] - Dp2[x + 2] - Dp1[x + 1]) % mod;
        Dp2[x] = (Dp2[x + 2] * 2 % mod - C(x + 2, 3) * Pow2[k - 1] % mod + C(x + 2, 2 * k + 1)) % mod;
        Dp2[x] = (Dp2[x] - 2 * Dp1[x + 2] + C(x + 2, 2) * Pow2[k - 1] - C(x + 2, 2 * k) - Dp2[x + 1]) % mod;
        res[x] = (res[x] + Dp1[x]) % mod;
    }
    cur = 0;
    for (int x = 1; x < k; x++)
    {
        cur = (cur + C(2, x) * Pow2[k - x - 1] % mod) % mod;
    }
    res[2] = (res[2] - 2 * cur % mod) % mod;
    for (int x = 3; x <= 2 * k - 2; x++)
    {
        cur = (cur - C(x, k) + C(x, 1) * Pow2[k - 1] % mod) % mod;
        res[x] = (res[x] - 2 * cur % mod) % mod;
    }
    cur = 0;
    for (int x = 1; x < k; x++)
    {
        cur = (cur + C(1, x) * Pow2[k - x - 1] % mod) % mod;
    }
    res[2] = (res[2] + 2 * cur % mod) % mod;
    for (int x = 3; x <= 2 * k - 2; x++)
    {
        cur = (cur - C(x - 1, k) + C(x - 1, 1) * Pow2[k - 1] % mod) % mod;
        res[x] = (res[x] + 2 * cur % mod) % mod;
    }
    for (int x = 2; x <= 2 * k - 2; x++)
    {
        cout << (res[x] % mod + mod) % mod << " ";
    }
}

int main()
{
    //freopen("D.INP", "r", stdin);
    //freopen("D.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    //cin >> test;
    for (int x = 1; x <= test; x++)
    {
        Inp();
        Exc();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 9852kb

input:

2

output:

7 3 

result:

ok 2 tokens

Test #2:

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

input:

3

output:

15 14 6 1 

result:

ok 4 tokens

Test #3:

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

input:

4

output:

31 43 36 19 6 1 

result:

ok 6 tokens

Test #4:

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

input:

5

output:

63 110 132 114 70 30 8 1 

result:

ok 8 tokens

Test #5:

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

input:

6

output:

127 255 384 448 400 272 136 47 10 1 

result:

ok 10 tokens

Test #6:

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

input:

7

output:

255 558 978 1401 1610 1478 1066 589 240 68 12 1 

result:

ok 12 tokens

Test #7:

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

input:

8

output:

511 1179 2292 3803 5250 5987 5576 4183 2482 1137 388 93 14 1 

result:

ok 14 tokens

Test #8:

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

input:

9

output:

1023 2438 5088 9398 14896 20038 22632 21250 16406 10282 5144 2006 588 122 16 1 

result:

ok 16 tokens

Test #9:

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

input:

10

output:

2047 4975 10896 21772 38360 58724 77184 86312 81448 64324 42112 22576 9744 3304 848 155 18 1 

result:

ok 18 tokens

Test #10:

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

input:

11

output:

4095 10070 22782 48209 92140 156292 232068 298744 330926 313422 252186 171122 97008 45368 17200 5155 1176 192 20 1 

result:

ok 20 tokens

Test #11:

score: 0
Accepted
time: 109ms
memory: 76156kb

input:

500000

output:

390220183 534638705 182393715 303662724 176884209 76063846 314206329 970463075 138271132 869076105 902568877 121426660 599330372 720576343 535733058 609095360 499854676 427738345 789967637 850801793 767689169 103101879 573005863 597231280 725469375 299015007 178535851 966708332 305629 940093777 7830...

result:

ok 999998 tokens

Test #12:

score: 0
Accepted
time: 19ms
memory: 21392kb

input:

72787

output:

863191949 852718765 363831665 964981186 487891193 263854743 37522806 18985671 265243835 698211861 413341848 452649596 684165069 41891590 781946347 633808644 213891845 90859042 654886506 681500079 853399752 536402628 160278411 189221861 144879826 449123001 395247186 477700669 245829076 740028721 3991...

result:

ok 145572 tokens

Test #13:

score: 0
Accepted
time: 8ms
memory: 13308kb

input:

29621

output:

625188972 186328126 837166229 677006047 662339899 556164288 627678499 464879587 574719635 860749906 37224574 952205162 612486418 67731480 127518779 222659320 311864904 739493528 441208728 656349279 675863661 193365665 871786422 429030382 542544944 65332274 279132780 886986640 23673291 260179258 1458...

result:

ok 59240 tokens

Test #14:

score: 0
Accepted
time: 55ms
memory: 50460kb

input:

287834

output:

839249597 106353691 541743754 176289649 331709790 90695814 581166563 660013633 12148749 777570497 239549256 50822832 928845641 783688014 527134794 967565837 8829067 728890387 532021836 723133136 271356603 442733913 109610442 872231778 997519892 627636901 942495046 612005045 480787271 380535891 31598...

result:

ok 575666 tokens

Test #15:

score: 0
Accepted
time: 71ms
memory: 62804kb

input:

372458

output:

238073678 125575487 257781224 432208434 926232022 985032784 972531646 156874450 242230869 958239072 623209641 963804956 760997596 492384034 248852029 480721426 727545366 871518883 526580215 340703419 119254798 894452847 503218079 466661994 21196998 64609258 607451189 866020376 472431142 833623174 95...

result:

ok 744914 tokens

Test #16:

score: 0
Accepted
time: 68ms
memory: 57480kb

input:

326174

output:

182767154 379158505 976650370 950752234 730142912 199366602 217176449 58415818 942059311 29041812 600728528 238722381 35842882 619426938 166582941 887411034 365366704 226747213 653768421 675658473 198607105 971515601 49241364 300610682 741576498 580333820 788122734 812899883 506754294 906735361 8477...

result:

ok 652346 tokens

Test #17:

score: 0
Accepted
time: 83ms
memory: 70048kb

input:

414785

output:

119371452 447324155 812098442 674259707 906095700 995739643 507821850 144836991 944844465 417859866 526136325 446179637 841143258 71594396 600687837 115917880 869472132 733304409 785178785 942797825 461532099 569481220 498200557 562246854 231360418 806781417 603555993 817444062 8765767 415391941 188...

result:

ok 829568 tokens

Test #18:

score: 0
Accepted
time: 11ms
memory: 16348kb

input:

52410

output:

109025791 520279794 997868526 544815757 1210333 262602454 444694081 215482612 359518123 630972106 469202475 93255040 356550496 552798085 978002390 758808807 872405738 26538225 591804454 180245449 487598812 486435998 100463040 636978431 131160375 54547501 21577758 600993423 54379208 278755072 3851668...

result:

ok 104818 tokens

Test #19:

score: 0
Accepted
time: 51ms
memory: 46816kb

input:

266488

output:

670591955 536664499 834582667 435202901 981715449 216606476 24885754 288060317 473842053 728197980 859018006 359189535 188879878 589394421 415307716 612098332 697672094 255330112 873094951 829240529 612715926 251238400 811393752 657428602 471660768 508314629 890321558 248471292 52873644 528909339 36...

result:

ok 532974 tokens

Test #20:

score: 0
Accepted
time: 51ms
memory: 43416kb

input:

235412

output:

838376130 82261816 749813798 853852768 548463514 590159263 767906723 873538508 681808483 793716931 81414518 387819437 489838184 649414809 971267048 518919507 299233671 402683441 670109161 673246099 315748962 982292160 524024775 990312514 930875705 394644470 79309906 651862394 296416662 949936814 511...

result:

ok 470822 tokens

Test #21:

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

input:

335028

output:

412572542 90575816 592590793 134956941 681546461 84123901 23797401 287575357 580630562 822219941 496015371 798714568 996561274 228437956 38964111 210338108 447304705 455001788 541599590 15999929 531678296 86106708 417035208 77019361 258493500 3295255 609295926 388289340 12082287 479955282 13536114 5...

result:

ok 670054 tokens

Test #22:

score: 0
Accepted
time: 110ms
memory: 74864kb

input:

490193

output:

89108812 9400903 759083927 482137918 881472778 819325246 469847190 224397125 941016878 318853318 823063910 192963094 253539854 195834928 305679610 177655853 744021959 486473727 952943524 80929181 726898580 419500987 86904978 500273473 864375683 752394278 447105311 649043680 568500692 716331790 79426...

result:

ok 980384 tokens

Test #23:

score: 0
Accepted
time: 99ms
memory: 76352kb

input:

494427

output:

224396630 171699844 874970651 366738496 188097388 20105024 923005591 475213547 862579354 219327984 402729610 343802472 824016768 274735056 606982614 720737421 379273500 527635893 326566225 588809571 892479263 956818966 119334763 921549067 728518606 341094293 734579914 96978341 54880988 441706555 375...

result:

ok 988852 tokens

Test #24:

score: 0
Accepted
time: 119ms
memory: 77060kb

input:

495456

output:

176309560 31132799 871206936 191727597 372664218 912078745 128667682 749015357 783582110 969205654 792240671 185634038 963924594 739384852 286035580 546230295 777033259 473035706 331715612 919733935 140740960 188303720 108317267 957369642 570466063 215525809 161735173 289750332 41787886 592639789 24...

result:

ok 990910 tokens

Test #25:

score: 0
Accepted
time: 109ms
memory: 75568kb

input:

499498

output:

10762491 87744479 29345176 330762125 67139471 859322674 517319159 444257903 287766504 323230886 614147692 179153449 789116746 632670050 42290946 845385229 648164696 260416611 791349068 162962424 446055973 201137312 796950696 787484329 797523547 634752612 675290933 712512594 448869911 573190874 93885...

result:

ok 998994 tokens

Test #26:

score: 0
Accepted
time: 111ms
memory: 75856kb

input:

493812

output:

613558532 754129691 624537960 491192546 52587972 335888580 918154485 412643191 632432095 756789608 652622556 498719566 684849283 923391920 735537543 543746954 46908287 213544787 692082087 977892286 329586609 673904401 701415241 768595797 918191698 628376968 628786912 839407278 263562545 942236399 70...

result:

ok 987622 tokens

Extra Test:

score: 0
Extra Test Passed