QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#736375 | #8486. Casino | Bucketsmith# | AC ✓ | 7ms | 3680kb | C++20 | 827b | 2024-11-12 10:34:11 | 2024-11-12 10:34:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int P = 1e9 + 7;
int c[3];
int check(int x) {
if(c[x] == 0) return 0;
vector<int> b(3);
b[x] ++;
while(c[1] + c[2] - b[1] - b[2]) {
if(b[x] + 1 > c[x]) return 0;
b[x] ++;
x ^= 3;
}
return 1;
}
int fact(int l, int r) {
int ret = 1;
while(l <= r) {
ret = ret * (i64)l % P;
l ++;
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for(int i = 1, x; i <= n; i ++) {
cin >> x;
c[x % 3] ++;
}
cout << (check(1) + check(2)) * (i64)fact(1, c[1]) * fact(1, c[2]) % P * fact(c[1] + c[2], n - 1) % P << "\n";
}
/*
2
5 2
1 3 3 2 2
4 3
1 4 2 1
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
3 100 21 892
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 11 19 30 32
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
3 4 298 28
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
5 24 27 38 46 94
output:
24
result:
ok 1 number(s): "24"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
5 72 84 11 51 21
output:
24
result:
ok 1 number(s): "24"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
5 84 51 12 6 69
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 30 66 27 36 60
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
10 98 39 37 19 45 73 83 42 73 3
output:
145152
result:
ok 1 number(s): "145152"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
10 89 34 37 93 47 12 56 26 3 51
output:
145152
result:
ok 1 number(s): "145152"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
10 73900926 31166686 581758479 266084782 136544545 864189216 334829736 346199618 111407115 84881126
output:
181440
result:
ok 1 number(s): "181440"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
10 374350674 408667992 305815278 141080955 705187668 53250180 908378583 123881433 725492762 607387956
output:
362880
result:
ok 1 number(s): "362880"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1000 24551 8084 73369 96016 90782 37319 35797 64970 52459 16561 61141 54762 81069 80237 48601 10843 1202 65279 4195 55258 89827 47014 78376 60803 51120 5914 48347 55895 88511 79208 49307 94324 26969 13367 92230 59021 13418 75515 19883 66005 49541 35616 49829 78359 709 63677 77152 45916 68528 54254 7...
output:
856284522
result:
ok 1 number(s): "856284522"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1000 48691 46538 83136 46036 71758 14694 13100 5781 97689 76006 44177 74676 93176 31340 41494 86339 55249 39544 46880 94896 88937 9345 75252 73414 98268 65240 49568 66888 50763 55836 3756 21457 52521 5787 84264 34850 95493 63753 55238 32771 81619 90007 17373 35056 51906 17186 62916 12882 7006 6353 9...
output:
104068234
result:
ok 1 number(s): "104068234"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
10000 67019 843459 643000 222974 581964 465799 161554 692789 783254 762805 936066 784466 490517 450618 416891 994505 531888 215338 892395 470532 660640 20964 726823 80040 260577 27895 940779 639052 398685 41661 629665 631243 76557 530475 411831 988371 47682 759130 885212 475131 641539 946530 793394 ...
output:
75531231
result:
ok 1 number(s): "75531231"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
10000 269718 881031 970470 349479 584418 519285 775143 745290 288480 908997 396750 777762 35241 790692 662334 614694 946332 384483 875742 24804 808923 597105 423093 980430 346848 66231 188568 8007 562785 631782 837633 992181 851259 764025 769746 300339 381234 110526 689535 453990 569928 487899 56223...
output:
291223019
result:
ok 1 number(s): "291223019"
Test #16:
score: 0
Accepted
time: 6ms
memory: 3588kb
input:
100000 719070 126576 692367 905361 377523 802356 775317 712461 34146 234291 655635 754425 934917 44338 381879 801225 423978 478229 359352 808089 591960 826566 410529 367422 808443 536325 231188 299760 990255 692928 474137 238317 147768 978636 927645 811116 35364 546072 129681 762951 284313 498120 66...
output:
534487341
result:
ok 1 number(s): "534487341"
Test #17:
score: 0
Accepted
time: 6ms
memory: 3608kb
input:
100000 275109 287835 38691 96075 271662 343521 979791 638907 115789 212055 478158 488622 45723 296841 223542 26004 548883 968859 615453 891404 203119 515400 469884 378579 935346 529125 185916 975651 467769 552543 905457 394152 481323 219522 929175 80859 32079 138888 407619 626844 364928 701685 41411...
output:
937699324
result:
ok 1 number(s): "937699324"
Test #18:
score: 0
Accepted
time: 6ms
memory: 3552kb
input:
100000 559619 635425 749380 537563 573710 778780 191335 164077 707134 990790 10442 499360 371410 376109 504714 383203 776297 893783 46850 912476 850635 121980 783086 611560 311557 302279 887742 100400 97167 21391 264448 801140 927460 821849 651923 496287 394110 387132 328332 244636 709580 863247 215...
output:
801257591
result:
ok 1 number(s): "801257591"
Test #19:
score: 0
Accepted
time: 3ms
memory: 3676kb
input:
100000 361476 26187 465800 826840 790696 679906 414403 911722 860847 805406 220958 513623 861776 4632 46985 466233 811305 326917 405995 672933 74940 208584 797269 70259 626188 828936 830119 902947 268882 103199 538657 950506 762990 944363 702463 240738 500695 333346 670627 351500 187418 694459 77921...
output:
625811000
result:
ok 1 number(s): "625811000"
Test #20:
score: 0
Accepted
time: 6ms
memory: 3588kb
input:
100000 678185 5790068 1551158 6260459 759956 1390682 2517307 6825143 2108618 854449 3573711 8747350 7893220 3637636 4102271 8431480 7291654 207859 9659011 1385040 4824439 3176911 9886195 3543109 7770563 9652727 8410505 6300844 470889 1338149 8849716 8470849 1853035 4348477 1472290 521270 1183064 685...
output:
650116699
result:
ok 1 number(s): "650116699"
Test #21:
score: 0
Accepted
time: 3ms
memory: 3628kb
input:
100000 8325313 989195 42377 7276214 2242630 7021318 3731183 7379099 7579906 4480864 9272614 2593960 5258414 7096181 9675146 6431900 7849097 6346753 4234618 8230412 1519181 2051701 5062271 9650992 9816784 4598753 4463902 9659339 2778493 3565912 8230520 4847035 8709077 2411107 2782614 4801391 7620817 ...
output:
178464958
result:
ok 1 number(s): "178464958"
Test #22:
score: 0
Accepted
time: 6ms
memory: 3600kb
input:
100000 22417628 15768346 37166352 33456312 91804378 20831948 75619049 40003312 31870801 86664525 81787955 77200916 15747834 27642743 39012656 737209 9846364 84062514 16536001 94518081 55350518 71821288 58568334 67550999 14658512 93917770 18688556 34400543 5352271 69777745 52637462 91873227 11592829 ...
output:
912437569
result:
ok 1 number(s): "912437569"
Test #23:
score: 0
Accepted
time: 6ms
memory: 3532kb
input:
100000 67027283 23061766 61177301 68029181 34232382 33984922 96463197 17148439 38828944 68470804 27029774 63697244 86431105 21312475 95924341 2961454 7567137 34273012 16541132 39505461 79625272 80889073 52744730 76784288 27888800 47702840 71062423 58527925 56390174 69845428 12580819 14451227 1746457...
output:
32413684
result:
ok 1 number(s): "32413684"
Test #24:
score: 0
Accepted
time: 3ms
memory: 3552kb
input:
100000 52931777 69116350 83743259 29269961 86791741 22752206 46737038 17243233 9097465 56306432 27286790 10180555 60096425 83546462 48124691 77435734 44057853 64673872 79184401 24664828 90557187 44308741 2816531 10847780 96197960 97728596 59476127 76056833 63814844 76761976 74008279 84024158 5233065...
output:
256478495
result:
ok 1 number(s): "256478495"
Test #25:
score: 0
Accepted
time: 6ms
memory: 3600kb
input:
100000 88240471 11472786 60479236 13861448 21574091 23468513 19343791 65237245 70845584 56815274 78043052 63792976 6941138 94557502 22488284 97344751 11563846 6432743 2076557 98435440 50806517 3670451 9162709 38927770 82513429 38157265 45136702 71602402 50101907 32426759 37911088 48235051 49964812 9...
output:
202969365
result:
ok 1 number(s): "202969365"
Test #26:
score: 0
Accepted
time: 7ms
memory: 3552kb
input:
100000 881643201 902233733 463382621 261166661 593626103 941406753 506118497 395515140 252678929 999787338 251946357 873741996 382418162 830622626 686827460 889631879 683596192 843051741 789187605 173486923 905110541 794445972 320399815 476292672 189928572 738483774 33584073 23279052 734495192 32683...
output:
724538641
result:
ok 1 number(s): "724538641"
Test #27:
score: 0
Accepted
time: 7ms
memory: 3588kb
input:
100000 518981955 73027794 259915248 440745025 880632132 194323000 768277631 793498620 391363501 939692455 408592626 378675434 205962444 369181326 988329351 76266796 865223992 48510658 912268078 805634706 484737193 615463749 237985366 196121099 80004509 681709317 813361870 443630218 169495616 3676011...
output:
941015803
result:
ok 1 number(s): "941015803"
Test #28:
score: 0
Accepted
time: 7ms
memory: 3524kb
input:
100000 270193083 747743325 335962227 281935854 313074525 10268019 548508018 316660347 593129094 78169506 566907411 273425040 881878911 290449260 765847383 228445317 199024671 503416236 261934923 797465313 995488197 398109930 843465192 369631506 645326448 925676949 611768538 235173999 631332702 23701...
output:
479780718
result:
ok 1 number(s): "479780718"
Test #29:
score: 0
Accepted
time: 7ms
memory: 3556kb
input:
100000 651775764 824294589 419827728 125070357 765871668 904566591 798018327 925715067 972425775 596189940 732798915 609888205 302265963 918057915 46327995 284782233 172514260 266800142 4780629 758832477 747280896 149135658 201810219 217833459 580692747 782287611 188031345 287089722 126132081 727498...
output:
286147707
result:
ok 1 number(s): "286147707"
Test #30:
score: 0
Accepted
time: 7ms
memory: 3556kb
input:
100000 999999999 999999999 1000000000 999999999 1000000000 1000000000 999999999 999999999 999999999 999999999 999999998 1000000000 1000000000 999999998 999999999 999999999 999999998 1000000000 999999998 999999998 1000000000 1000000000 999999998 1000000000 1000000000 999999999 999999999 999999999 100...
output:
0
result:
ok 1 number(s): "0"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
10 732532342 934555287 18001444 213608504 265641339 723535229 611816146 814264164 640481225 332198826
output:
0
result:
ok 1 number(s): "0"
Test #32:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1000 88566 85717 36414 75619 42267 51381 67287 41903 6207 27638 78414 60450 30884 82865 20251 39935 80380 67731 53262 42171 88655 32924 71430 36067 76120 11040 64123 33556 12680 73929 97237 8322 65026 98098 49010 87346 26397 22733 1060 22719 78918 41119 42833 64696 1243 35327 65809 27552 43920 31450...
output:
0
result:
ok 1 number(s): "0"
Test #33:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
10000 872634 70780 580571 874420 199106 515056 789708 909797 99111 236906 902476 316627 885036 269374 411113 71532 17863 711059 703331 649649 204131 919204 465070 306808 872158 370050 656500 969707 647052 220495 766545 77191 575282 431684 146965 175582 101899 687020 96453 256533 954119 841127 81947 ...
output:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 6ms
memory: 3540kb
input:
100000 446260 239046 912376 118430 904994 139296 869714 841584 438270 962320 255189 446247 413480 599172 162693 887457 226597 22187 907655 373505 220252 935484 200229 807791 498906 475503 725005 80405 2127 155266 381330 316195 155983 883381 702826 5515 116499 907982 702254 345797 473013 440791 55517...
output:
0
result:
ok 1 number(s): "0"
Test #35:
score: 0
Accepted
time: 6ms
memory: 3560kb
input:
100000 4130858 2364160 5163876 1878701 5800307 3981828 4698472 4396699 9523870 2453271 2151183 7973273 5654115 6232952 342089 2011953 257034 1942683 1052507 1808478 6203634 6691109 3117531 5913746 9053451 1964018 729141 1078706 7349980 2637712 6865705 1559957 7603581 757697 6682954 674824 9042590 17...
output:
0
result:
ok 1 number(s): "0"
Test #36:
score: 0
Accepted
time: 3ms
memory: 3556kb
input:
100000 46136614 20882502 8509783 7193913 69863529 60376929 19335019 55950612 60462766 77210238 9099654 87124493 5122385 41860623 93362616 88076696 86493492 46851240 39625940 53062797 67999804 99021446 13909488 7567529 43150546 71751174 12759529 90195723 54169187 7637545 18436061 48621239 78003680 61...
output:
0
result:
ok 1 number(s): "0"
Test #37:
score: 0
Accepted
time: 7ms
memory: 3548kb
input:
100000 927261728 297134002 696302759 105313417 834706060 113205687 819890134 436970805 780953716 255914744 391626680 269365128 244531974 847264211 293519816 297172542 869189796 146028796 202317809 476013475 467788134 662162940 257982740 763897882 901639062 725755309 363692422 717543575 851651634 698...
output:
0
result:
ok 1 number(s): "0"
Test #38:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
1 552979905
output:
0
result:
ok 1 number(s): "0"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1 436096036
output:
1
result:
ok 1 number(s): "1"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 909146756
output:
1
result:
ok 1 number(s): "1"
Test #41:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 578609385 78087591
output:
0
result:
ok 1 number(s): "0"
Test #42:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
2 461725513 651636439
output:
2
result:
ok 1 number(s): "2"
Test #43:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 639808937 520152578
output:
2
result:
ok 1 number(s): "2"
Test #44:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 309271566 57436845 247106784
output:
0
result:
ok 1 number(s): "0"
Test #45:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
3 487354990 485761498 840887338
output:
0
result:
ok 1 number(s): "0"
Test #46:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
3 665438417 354277640 139700597
output:
0
result:
ok 1 number(s): "0"
Test #47:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
10 931560093 950918019 499927185 31634262 264403551 674521716 35423385 878037234 252367386 211494237
output:
0
result:
ok 1 number(s): "0"
Test #48:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
10 404610814 524466862 798740446 762296443 243752806 219000493 615452266 221221222 473301541 198831124
output:
0
result:
ok 1 number(s): "0"
Test #49:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
10 287726945 392983004 242777897 933150113 77877869 203670758 640191545 564405212 399268403 776102603
output:
0
result:
ok 1 number(s): "0"
Test #50:
score: 0
Accepted
time: 7ms
memory: 3604kb
input:
100000 64286526 699569766 171369435 42273369 256909398 654256680 714409074 981959349 598045335 45361773 912570387 175067931 601898928 647730711 872612451 51706029 687878232 556083381 543552579 313381248 421865676 23839476 288543330 484586751 717806403 67392294 730201008 210537084 723203202 309016512...
output:
0
result:
ok 1 number(s): "0"
Test #51:
score: 0
Accepted
time: 6ms
memory: 3588kb
input:
100000 947402656 568085908 765149989 67902850 531225949 343959649 149213764 325143340 524012194 32698660 146639341 936627673 244731724 527332954 944839669 129153949 971125957 560587837 416983303 457678192 568929424 349019959 803650840 706461133 740120260 937702504 738262525 495994651 746917513 20131...
output:
0
result:
ok 1 number(s): "0"
Test #52:
score: 0
Accepted
time: 7ms
memory: 3540kb
input:
100000 420453377 141634754 358930544 93532328 365351012 183405725 878985746 373360031 449979056 609970139 820899782 993154715 182531813 847126685 461777291 56858762 399597872 714835397 585381320 751718243 715993175 969167738 318758351 73559711 762434120 513045416 451356749 76419512 625407635 9361625...
output:
0
result:
ok 1 number(s): "0"
Extra Test:
score: 0
Extra Test Passed