QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799667 | #9839. Selection Sort Count | rotcar07 | AC ✓ | 14ms | 7648kb | C++23 | 645b | 2024-12-05 16:57:35 | 2024-12-05 16:57:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
constexpr int maxn=2e5+5;
typedef long long ll;
constexpr ll mod=998244353;
ll fac[maxn],inv[maxn];
ll qpow(ll a,int b){
ll ans=1;
while(b){
if(b&1) ans=ans*a%mod;
a=a*a%mod,b>>=1;
}
return ans;
}int a[maxn];
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<n;i++) cin>>a[i];
for(int i=fac[0]=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
inv[n]=qpow(fac[n],mod-2);
for(int i=n;i>=1;i--) inv[i-1]=inv[i]*i%mod;
ll ans=1;
for(int i=1;i<n;i++) ans=ans*fac[a[i+1]+1]%mod*inv[a[i]]%mod*inv[a[i+1]+1-a[i]]%mod;
cout<<ans<<'\n';
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5708kb
input:
3 1 1
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
6 0 1 1 1 0
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5724kb
input:
6 0 1 2 1 1
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 0ms
memory: 5720kb
input:
8 3 3 2 1 2 1 1
output:
24
result:
ok single line: '24'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5780kb
input:
9 1 5 5 4 3 2 1 1
output:
72
result:
ok single line: '72'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5724kb
input:
10 2 2 3 4 4 3 3 2 1
output:
3600
result:
ok single line: '3600'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5636kb
input:
11 1 1 3 3 4 4 4 3 2 1
output:
8000
result:
ok single line: '8000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5652kb
input:
12 3 5 5 4 4 4 4 4 3 2 1
output:
75000
result:
ok single line: '75000'
Test #9:
score: 0
Accepted
time: 14ms
memory: 7580kb
input:
200000 14 24 34 49 58 65 71 79 100 111 116 123 128 139 146 151 159 162 169 172 187 197 203 213 219 221 232 240 251 258 261 266 276 282 294 300 306 318 324 331 344 346 360 364 372 377 386 390 405 407 415 422 430 435 442 447 453 458 469 474 485 493 500 510 511 518 526 535 547 551 556 560 565 570 579 5...
output:
54993472
result:
ok single line: '54993472'
Test #10:
score: 0
Accepted
time: 13ms
memory: 7580kb
input:
200000 8 17 27 40 53 60 68 82 92 102 110 116 130 141 149 163 174 182 188 198 205 217 227 232 239 244 251 256 268 275 282 289 302 310 317 326 334 345 354 358 364 377 376 385 395 402 407 415 422 430 439 449 456 461 469 480 490 495 500 507 512 519 527 531 534 542 547 556 562 571 578 585 593 608 620 630...
output:
261245878
result:
ok single line: '261245878'
Test #11:
score: 0
Accepted
time: 13ms
memory: 7628kb
input:
200000 10 19 29 45 52 61 66 78 84 94 105 112 117 129 137 144 153 165 179 191 200 202 213 226 229 236 246 249 254 260 263 272 282 295 301 307 311 316 323 330 332 340 349 351 354 365 370 383 390 399 408 414 420 427 434 445 453 459 468 474 482 487 489 495 501 508 512 516 522 529 542 549 558 564 568 578...
output:
537386936
result:
ok single line: '537386936'
Test #12:
score: 0
Accepted
time: 14ms
memory: 7648kb
input:
200000 12 17 27 37 43 52 57 65 76 81 88 98 104 117 128 132 138 140 145 156 163 174 190 198 202 206 210 218 226 235 251 260 273 279 285 294 299 305 313 320 329 340 351 365 377 385 396 403 413 419 424 428 431 436 439 439 445 451 456 464 467 478 487 492 501 502 508 516 527 533 544 548 555 561 568 576 5...
output:
141817197
result:
ok single line: '141817197'
Test #13:
score: 0
Accepted
time: 7ms
memory: 7632kb
input:
200000 7 11 23 30 37 47 55 64 77 85 95 103 114 119 132 136 143 151 163 172 183 190 197 205 212 215 221 236 244 251 264 275 286 297 303 313 323 331 345 353 358 364 375 385 397 409 415 421 429 436 441 449 455 459 467 474 480 483 488 497 502 509 519 525 532 535 543 550 559 562 569 575 582 590 601 607 6...
output:
660647651
result:
ok single line: '660647651'
Test #14:
score: 0
Accepted
time: 3ms
memory: 6256kb
input:
92372 13 25 35 42 46 51 59 67 77 83 90 99 112 116 119 127 135 142 150 158 162 170 177 186 201 206 215 223 227 232 239 245 253 260 267 274 285 290 293 300 304 307 311 315 320 324 331 339 341 345 353 355 356 360 367 376 383 388 397 401 406 414 422 429 436 442 452 457 465 475 481 487 495 506 512 515 52...
output:
191304516
result:
ok single line: '191304516'
Test #15:
score: 0
Accepted
time: 2ms
memory: 4080kb
input:
23572 7 23 31 44 50 58 67 72 77 80 85 95 103 109 118 122 124 130 135 139 144 151 154 158 165 170 179 188 199 201 207 216 224 226 228 232 238 244 246 253 260 263 273 274 279 289 296 303 308 315 324 329 335 340 346 351 355 360 364 368 373 383 386 389 396 398 405 410 415 418 422 433 439 444 449 454 459...
output:
483093923
result:
ok single line: '483093923'
Test #16:
score: 0
Accepted
time: 5ms
memory: 6992kb
input:
132313 10 23 32 42 56 60 67 76 87 98 104 112 122 131 143 157 167 170 177 187 192 198 209 215 220 229 237 247 253 260 266 275 281 288 292 297 302 309 317 323 329 337 342 346 355 362 373 378 386 388 398 403 409 415 420 428 435 439 439 448 454 464 469 474 481 487 493 501 507 514 526 530 537 544 549 552...
output:
793042765
result:
ok single line: '793042765'
Test #17:
score: 0
Accepted
time: 2ms
memory: 6240kb
input:
63513 8 15 31 40 46 53 60 70 75 81 86 94 103 116 129 135 144 152 161 166 172 181 186 194 200 205 214 221 226 231 237 242 253 259 265 272 278 282 286 290 294 302 308 312 316 318 326 328 335 338 351 356 363 368 370 383 389 392 397 403 412 416 422 425 429 432 441 447 456 460 468 470 475 480 484 490 493...
output:
189745812
result:
ok single line: '189745812'
Test #18:
score: 0
Accepted
time: 13ms
memory: 7544kb
input:
194712 12 22 32 42 54 61 71 82 91 96 105 110 120 132 148 154 161 172 177 180 187 195 206 217 227 235 247 251 257 268 275 283 292 303 314 320 325 337 343 348 351 356 363 367 370 377 386 394 403 410 418 422 425 429 437 447 457 460 464 468 475 482 487 494 503 513 518 525 530 536 542 552 556 567 576 581...
output:
783970538
result:
ok single line: '783970538'
Test #19:
score: 0
Accepted
time: 12ms
memory: 7520kb
input:
199946 1 1 2 2 1 0 1 1 1 1 1 1 1 1 2 2 2 2 3 4 4 4 3 2 1 1 1 3 3 2 1 2 2 2 2 3 3 4 4 4 3 2 2 2 4 3 2 3 5 4 3 3 4 3 2 2 2 1 3 5 4 3 3 3 4 3 3 2 5 4 3 3 4 6 5 6 7 6 5 5 5 5 5 4 3 5 5 4 5 6 7 7 6 5 5 4 3 4 5 5 4 4 5 4 4 3 2 2 7 6 7 6 6 5 5 5 4 6 6 6 6 7 7 6 5 4 3 4 3 6 7 6 5 7 8 8 7 6 5 6 6 6 7 7 6 6 5...
output:
260637471
result:
ok single line: '260637471'
Test #20:
score: 0
Accepted
time: 12ms
memory: 7512kb
input:
199981 0 0 0 0 1 1 2 2 2 2 3 2 2 1 1 0 1 1 1 1 1 2 2 2 2 2 2 2 2 1 0 1 1 2 3 2 1 2 2 3 4 3 3 3 2 5 5 5 4 3 3 2 3 5 5 4 3 2 3 3 4 3 2 1 1 3 2 4 5 5 6 5 5 4 4 3 2 4 4 4 4 6 5 5 4 4 4 4 5 4 5 5 5 4 4 5 5 5 5 5 6 6 6 6 6 5 5 6 5 7 7 6 5 6 7 8 8 8 7 6 5 6 5 4 5 6 5 5 5 6 5 5 6 5 7 6 6 5 7 6 6 6 6 5 4 4 3...
output:
327975857
result:
ok single line: '327975857'
Test #21:
score: 0
Accepted
time: 14ms
memory: 7568kb
input:
199938 944 1896 2866 3774 4659 5473 6344 7196 8043 8931 9790 10673 11587 12409 13266 14053 14910 15781 16615 17440 18285 19112 19983 20857 21724 22617 23491 24330 25203 26058 26944 27736 28581 29411 30248 31093 31934 32752 33573 34365 35228 36013 36879 37675 38495 39285 40061 40870 41671 42410 43197...
output:
737901766
result:
ok single line: '737901766'
Test #22:
score: 0
Accepted
time: 10ms
memory: 7488kb
input:
199936 859 1747 2655 3543 4380 5249 6144 7057 7929 8832 9755 10646 11538 12418 13306 14153 15034 15901 16723 17581 18490 19335 20189 21058 21930 22774 23637 24513 25307 26090 26907 27710 28560 29365 30196 31013 31827 32643 33482 34325 35125 35897 36698 37441 38214 39027 39837 40632 41414 42195 43019...
output:
734330267
result:
ok single line: '734330267'
Test #23:
score: 0
Accepted
time: 11ms
memory: 7572kb
input:
199913 0 0 0 0 2 2 1 2 2 1 1 2 1 1 1 1 2 3 2 2 2 2 4 3 2 2 1 2 1 1 1 1 1 1 1 3 4 4 3 3 2 2 3 3 2 2 2 1 1 4 5 4 3 2 1 1 1 3 4 4 4 4 4 3 3 3 2 2 3 3 5 4 5 4 4 3 5 4 3 3 3 2 2 1 1 0 0 1 2 3 3 2 2 3 4 5 4 4 4 3 5 4 3 3 2 3 3 5 4 3 2 2 2 2 3 2 2 3 4 3 3 4 4 4 3 3 4 3 3 3 3 4 4 3 2 1 1 2 3 3 4 3 4 3 2 1 3...
output:
465226196
result:
ok single line: '465226196'
Test #24:
score: 0
Accepted
time: 11ms
memory: 7560kb
input:
199977 1 1 0 2 1 0 1 1 0 0 0 1 2 2 2 1 3 4 3 2 1 1 1 1 1 1 3 4 3 2 2 2 4 3 2 3 2 1 1 0 0 3 4 4 4 4 4 3 3 2 1 3 3 4 3 3 4 4 4 5 5 4 3 2 3 2 2 4 4 4 4 5 4 3 2 1 3 3 4 3 2 2 3 4 3 4 3 4 4 4 4 4 3 2 3 3 3 2 1 3 3 2 5 5 4 3 2 1 1 1 5 5 4 3 2 6 5 4 3 4 4 4 4 4 4 4 3 3 3 3 3 2 3 3 3 3 4 4 4 4 4 4 3 2 3 3 3...
output:
842179133
result:
ok single line: '842179133'
Test #25:
score: 0
Accepted
time: 14ms
memory: 7576kb
input:
199970 12923 25831 38839 51769 64712 77490 90291 103459 116250 128848 141406 154080 166224 177621 187837 195968 199953 199952 199951 199950 199949 199948 199947 199946 199945 199944 199943 199942 199941 199940 199939 199938 199937 199936 199935 199934 199933 199932 199931 199930 199929 199928 199927...
output:
962295344
result:
ok single line: '962295344'
Test #26:
score: 0
Accepted
time: 3ms
memory: 7568kb
input:
199995 12849 25715 38677 51566 64447 77383 90360 102940 115838 128643 141396 153974 166014 177490 187768 196035 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199961 199960 199959 199958 199957 199956 199955 199954 199953 199952...
output:
617825528
result:
ok single line: '617825528'
Test #27:
score: 0
Accepted
time: 10ms
memory: 7636kb
input:
199981 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
1
result:
ok single line: '1'
Test #28:
score: 0
Accepted
time: 11ms
memory: 7636kb
input:
199936 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
865341002
result:
ok single line: '865341002'
Test #29:
score: 0
Accepted
time: 7ms
memory: 7588kb
input:
199986 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
3926933
result:
ok single line: '3926933'
Test #30:
score: 0
Accepted
time: 7ms
memory: 7632kb
input:
199954 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
206212122
result:
ok single line: '206212122'
Test #31:
score: 0
Accepted
time: 10ms
memory: 7512kb
input:
199906 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
977474241
result:
ok single line: '977474241'
Test #32:
score: 0
Accepted
time: 11ms
memory: 7516kb
input:
199902 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
966007328
result:
ok single line: '966007328'
Test #33:
score: 0
Accepted
time: 14ms
memory: 7452kb
input:
199913 199912 199911 199910 199909 199908 199907 199906 199905 199904 199903 199902 199901 199900 199899 199898 199897 199896 199895 199894 199893 199892 199891 199890 199889 199888 199887 199886 199885 199884 199883 199882 199881 199880 199879 199878 199877 199876 199875 199874 199873 199872 199871...
output:
1
result:
ok single line: '1'
Test #34:
score: 0
Accepted
time: 9ms
memory: 7516kb
input:
199909 178852 199906 199905 199904 199903 199902 199901 199900 199899 199898 199897 199896 199895 199894 199893 199892 199891 199890 199889 199888 199887 199886 199885 199884 199883 199882 199881 199880 199879 199878 199877 199876 199875 199874 199873 199872 199871 199870 199869 199868 199867 199866...
output:
290019347
result:
ok single line: '290019347'
Test #35:
score: 0
Accepted
time: 7ms
memory: 7568kb
input:
199928 131698 177639 199923 199922 199921 199920 199919 199918 199917 199916 199915 199914 199913 199912 199911 199910 199909 199908 199907 199906 199905 199904 199903 199902 199901 199900 199899 199898 199897 199896 199895 199894 199893 199892 199891 199890 199889 199888 199887 199886 199885 199884...
output:
886839717
result:
ok single line: '886839717'
Test #36:
score: 0
Accepted
time: 14ms
memory: 7568kb
input:
199999 7990 101866 180160 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 199961 199960 199959 199958 199957 199956 199955 199954 1...
output:
232582743
result:
ok single line: '232582743'
Test #37:
score: 0
Accepted
time: 14ms
memory: 7588kb
input:
199972 24057 30723 40979 86463 93744 150789 162326 180551 199953 199952 199951 199950 199949 199948 199947 199946 199945 199944 199943 199942 199941 199940 199939 199938 199937 199936 199935 199934 199933 199932 199931 199930 199929 199928 199927 199926 199925 199924 199923 199922 199921 199920 1999...
output:
593182869
result:
ok single line: '593182869'
Test #38:
score: 0
Accepted
time: 10ms
memory: 7588kb
input:
199900 4924 10024 19699 30165 39477 40042 46499 50784 63747 118171 132591 151577 182822 193953 196452 199854 199853 199852 199851 199850 199849 199848 199847 199846 199845 199844 199843 199842 199841 199840 199839 199838 199837 199836 199835 199834 199833 199832 199831 199830 199829 199828 199827 19...
output:
134502039
result:
ok single line: '134502039'
Test #39:
score: 0
Accepted
time: 0ms
memory: 5740kb
input:
2 0
output:
1
result:
ok single line: '1'
Test #40:
score: 0
Accepted
time: 1ms
memory: 5776kb
input:
2 1
output:
1
result:
ok single line: '1'
Extra Test:
score: 0
Extra Test Passed