QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369688#8051. Colorful GraphSysweaAC ✓48ms5076kbC++17871b2024-03-28 16:25:012024-03-28 16:25:02

Judging History

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

  • [2024-03-28 16:25:02]
  • 评测
  • 测评结果:AC
  • 用时:48ms
  • 内存:5076kb
  • [2024-03-28 16:25:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef long long ll;
typedef pair<int, int> pii;
void solve() {
    int n, d; cin >> n >> d;
    vector<int> a(n);
    int sum = 0;
    for (auto &x: a) cin >> x, sum += x;
    sort(a.begin(), a.end());
    if (d == 1) {
        ll ans = 0;
        ans = (ll)(sum - 1) * sum / 2;
        cout << ans << '\n';
    }
    else if (d == 2) {
        ll ans = 0;
        for (auto x: a) {
            ans += (ll)x * (sum - x);
        }
        ans /= 2;
        cout << ans << '\n';
    } else {
        ll ans = 0;
        for (int i = 0; i < n; i ++ )
            ans += (ll)a[i] * (n - i - 1);
        cout << ans << '\n';
    }
}
int main() {
    cin.tie(0) -> sync_with_stdio(0);
    int _; cin >> _;
    while (_ -- )
        solve();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3540kb

input:

4
3 3
2 2 1
3 3
2 3 3
5 2
1 1 1 1 1
1 1
1

output:

4
7
10
0

result:

ok 4 number(s): "4 7 10 0"

Test #2:

score: 0
Accepted
time: 32ms
memory: 3840kb

input:

100000
4 1
83098469 352917937 251886575 311597499
1 1
680623262
5 5
120926686 352389253 123867424 344504569 46843792
4 3
37256702 333521752 389274366 182386089
3 1
312088641 62549248 624200228
5 1
49520484 309629001 6706501 130990505 212289223
4 2
283532046 237187900 190789905 199836040
5 2
82438225...

output:

499500604260364960
231624012047448691
1142394643
810064036
498838791486633786
251436730080577041
308783790647218570
164499334436079248
207992038926801095
1747582724654842
230435391500405412
363663543890512216
201191164497528778
293583914240718681
29912063660456952
313148137354523551
4332170853400846...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 47ms
memory: 3536kb

input:

90804
8 2
95666673 73753797 42147450 151109256 267697435 55388459 262480445 4501691
8 7
7608411 17932821 12607738 165362046 278782944 136040586 303910945 31264100
1 1
263320317
1 1
671913093
1 1
653602159
2 1
188936499 529216899
7 3
98836905 183914517 22827878 87025513 13698287 221186568 207259184
7...

output:

362437615272784425
1361254604
34668794540830086
225733601936456778
213597890797929561
257872151170396503
1416030097
288354304155073733
462468993481100166
178563447364153365
337513715037340185
1568626350
468023176734329055
139628647637362592
355892734075666528
453638056295605951
365223278279662789
10...

result:

ok 90804 numbers

Test #4:

score: 0
Accepted
time: 36ms
memory: 3796kb

input:

9937
15 14
100974231 96281351 49026861 124016782 43566537 27141063 159304381 60570210 31931263 65606566 12021046 35736542 87035510 42522892 24724840
14 2
47322045 18663301 109345115 2175600 127517529 127970649 209059601 117584477 85888372 44162618 56248657 3587962 4707105 35783323
32 31
11490607 209...

output:

4252851411
430803914309848469
8385607977
425680983018047428
466114559706725195
23677462656
466177728884604544
497759222682863571
424775621594063262
445282802556344697
460722385397808423
4635534284
454683276483684689
379624380106602694
476181894454555970
475414720521677427
13247949115
13543098050
469...

result:

ok 9937 numbers

Test #5:

score: 0
Accepted
time: 43ms
memory: 3588kb

input:

982
894 593
746337 2396537 1174929 3277287 267258 1994539 885085 173977 4089105 15676 1655536 3622685 2565176 56805 197790 2100019 741733 3809071 1723685 103593 850096 326147 791411 607869 292572 809812 844145 1262781 95199 1844118 103912 1918142 1027465 648492 148603 1182481 1240644 3561230 67565 1...

output:

224123963351
495148849760493825
80878540527
499831765653778876
497505163393337946
496939271919813451
11187781337
116559609758
119829762201
486256638727512894
40851567111
499889482607722026
497917881448348307
497263486505487278
497509030126792708
63890625610
488631326163945903
499256946769372785
1907...

result:

ok 982 numbers

Test #6:

score: 0
Accepted
time: 48ms
memory: 3608kb

input:

97
8581 1
33572 85417 8839 102435 26020 23577 79925 116395 1015 243545 19999 41186 190467 175850 41607 90384 106882 82641 84907 187193 78372 213627 30085 147682 57888 133302 136452 532653 32023 129182 89365 18911 106122 4172 49282 32558 167211 4107 17107 19234 255022 100190 70991 32594 156034 131460...

output:

499934788626400291
499805471081269490
499236978315959788
499119598866882127
499478018747480986
499710564386660866
1489442068034
499891774357028796
2290512359878
496337292478499053
498278225808325612
1733781708431
1317955701831
499159165299046266
1691317099770
1964890882959
499988733563467011
4999142...

result:

ok 97 numbers

Test #7:

score: 0
Accepted
time: 41ms
memory: 3872kb

input:

8
41764 1
48652 4263 15277 27499 9691 47479 38019 6822 13639 16020 8788 51211 118361 39925 79282 51614 20903 18687 24157 31640 2041 72077 60147 28734 7543 31979 36176 70664 1609 27591 3807 31213 13483 11708 8886 2056 6318 10994 3107 22381 37006 70096 27484 3474 27805 6929 51207 19136 5841 2208 26822...

output:

499983361638419841
499996094507626465
499933971356399023
499911247412877683
499995585509743905
499939984204338701
499958183708068959
499908402181030900

result:

ok 8 numbers

Test #8:

score: 0
Accepted
time: 42ms
memory: 3828kb

input:

50000
9 1
9301599 16418778 251526051 99040670 12397330 267738328 4946893 122934172 17786911
9 1
92321822 65428780 73499591 61305540 803687 8155796 469479641 32434338 94313093
10 1
171742720 80136146 92951884 98694530 300257977 25248388 32344241 156013674 3357993 3334890
9 1
54235096 89964382 1060598...

output:

321674770779102546
402970607382866328
464727477968382903
234279292940442921
469085658865465461
488971195893680451
447130102231991181
499247018204456745
460460373802257403
438911096146273653
416973705567802866
437398966871993946
370886152925635903
327470364712501570
455539900853267506
379925298064781...

result:

ok 50000 numbers

Test #9:

score: 0
Accepted
time: 40ms
memory: 3828kb

input:

50000
9 2
80672280 142137210 7426264 98546844 217467971 56741286 84007271 184027856 128579762
9 2
70466607 110523403 133302135 3090021 40660090 17504881 140484392 139327675 21500713
9 2
237130621 42298540 6444163 242849123 10702908 147424874 64994545 80458953 86145139
10 2
43579222 7910308 236613836...

output:

427383944527674773
190804682324729723
343271716545777061
371545977995717956
353030806951436548
270221151174405279
424027909161673407
396786758423364786
332366200361675493
310811932305985094
383921988693918825
382560599945857991
360725231438694744
324879247741491060
342007335389727012
349471121936923...

result:

ok 50000 numbers

Test #10:

score: 0
Accepted
time: 40ms
memory: 3504kb

input:

50000
9 3
18485566 29337870 108379178 261458694 172667434 19702985 44189398 252970322 73863809
9 3
119602000 49668437 55443728 267237538 44310765 56896826 320152 76107740 175670749
9 3
56733546 206251938 1525888 38632102 121254313 40541208 42808712 30848936 12439661
10 3
52580932 74343261 90163546 3...

output:

1901677593
1758751106
1002851230
2279758910
1307996092
1381450510
1810254526
2319404535
2150257944
1897124676
2742472795
1833815147
2521263452
2105118389
2820640101
2261494726
1608137772
1929801704
1485188994
1604196440
2208752693
2592093475
1931772398
2179546749
2268516791
2479549337
1309287617
188...

result:

ok 50000 numbers

Test #11:

score: 0
Accepted
time: 34ms
memory: 3548kb

input:

5000
98 1
5422461 8649902 3273704 6396813 1299567 22108262 3752719 7109526 1336018 7630838 2861481 1296075 7942087 7556630 3480940 3674176 7364716 4738000 4898297 6443767 9922013 7217047 16287964 16391805 18613082 14760811 5901460 2768891 11624990 47917350 9090631 12407249 10563421 27580925 7363450 ...

output:

495430513583210325
486592765057631953
497738258039698665
490895234604620310
483292419889583811
492214321190533425
478866495855105280
483589140903903651
487786251474107691
495325231610131131
490678329052676628
496339275592917525
497567627934369453
491219298123572215
476050795660904778
493637793135006...

result:

ok 5000 numbers

Test #12:

score: 0
Accepted
time: 38ms
memory: 3532kb

input:

5000
93 2
9926915 6754679 8630348 18116780 12928839 21543984 15763855 372637 10591894 2807010 5134977 25460242 20051090 6326566 6230720 14865046 7288754 1816252 17436818 1639361 5439232 4312559 976327 14715416 11521144 4486008 596290 4517317 5715274 3326029 9654746 25336444 10141605 3357771 1623401 ...

output:

487282008745744858
488497068901253262
484974901979532494
482841832551103976
484681976532194427
478585199626163122
478724321167938838
480023820757262507
486453038120559557
476602089652612381
475056669557074209
486757654510467584
489324081560643651
479962822858900509
465662534301503411
485095716722994...

result:

ok 5000 numbers

Test #13:

score: 0
Accepted
time: 38ms
memory: 3552kb

input:

5000
91 3
396812 16109456 23285521 5150861 7246487 5807217 4946788 3277426 34801783 8037874 9672317 8069850 2362073 8143219 30796 5136480 20748744 950769 8820005 4536876 12575108 16618566 6623842 1046010 23456620 15140103 10008411 13077712 7692586 11253192 15421176 7200181 3808371 13792851 735844 83...

output:

25188782275
23073983056
23853242675
21706853286
22265527866
25503455228
23995310022
22864112654
23036999466
23749281174
22958098688
21631602976
22933498781
21774550624
18890295284
22321392351
22260842779
21359838785
22478974873
22675019081
24475015088
24428692277
22121973373
22542219617
23475925412
...

result:

ok 5000 numbers

Test #14:

score: 0
Accepted
time: 38ms
memory: 3792kb

input:

500
948 1
1485193 595560 111363 483265 263101 2709809 1238420 551891 3130560 594458 1353489 278141 2414 25789 1485234 256293 1538068 158417 988482 1742716 547649 700583 136107 336792 437960 1865734 408529 1266357 1877760 1218169 1553004 3246479 973958 486858 1131360 255028 2343014 59960 540442 30410...

output:

499589163927828660
498826698626847045
499581489112352101
498832403937326781
498025862964856005
499900982402727753
499605889192286766
499798394826421125
498294667065198655
499748919028743828
496861408398289278
499888994661776566
498633638249859456
499751827302488706
498793648021666740
499631318488096...

result:

ok 500 numbers

Test #15:

score: 0
Accepted
time: 41ms
memory: 3556kb

input:

500
994 2
117630 456661 3811483 83320 967786 647820 143629 1697861 3427260 1098952 3408958 718039 309359 593747 174192 679697 50806 2011398 1510355 509380 284704 1796856 82946 7387 1273269 162305 1533663 175789 396125 1821562 1017793 1558021 952932 4848428 809183 170007 3328063 568403 2124154 121908...

output:

497054814339172725
498039330588615661
498528932671373760
497903294373715194
498309841369391794
496310601945463872
498837461474036971
496202378185424923
498427408270725078
495969577526834160
498140986718629775
498427560800080791
498994576972032530
497453482800105363
498048358646475300
498895724839545...

result:

ok 500 numbers

Test #16:

score: 0
Accepted
time: 37ms
memory: 3552kb

input:

500
939 3
1474859 502406 1146206 2927941 462764 2161371 1857948 140259 1637075 748077 724063 266263 872505 252527 1130307 462981 130337 1685023 766835 178944 1591227 212353 1269014 286413 650359 516957 32510 270040 976761 1205982 31717 421605 537887 2008225 218481 1112418 1016378 1096027 1199921 375...

output:

241644537585
231656169078
251760545036
234498032375
237126812462
233011688312
230252899966
232920092171
231258387601
239915304513
241205792437
238552573997
235172035373
226401259568
243071867330
239346334566
227529953671
249028809070
238338876847
237341817127
242605651669
222705326561
233908997324
2...

result:

ok 500 numbers

Test #17:

score: 0
Accepted
time: 45ms
memory: 3584kb

input:

50
9437 1
259233 92121 13438 143823 13991 11437 379064 62882 72169 63459 188321 78638 202027 228862 188566 70043 97290 300846 65806 91665 66655 292425 53469 27991 6159 4825 123529 177499 36986 61504 192941 73698 10810 67922 43804 386861 243928 81427 52040 258715 21649 250136 26477 71575 33314 130317...

output:

499998377501316253
499945639977586341
499998590500993345
499848754939264396
499949993750375028
499989310557132705
499953831565811365
499984461620722491
499892460283017285
499783729891439071
499937571448783665
499926627191982000
499966571058765735
499939881307237260
499936145538826296
499827843321512...

result:

ok 50 numbers

Test #18:

score: 0
Accepted
time: 45ms
memory: 3580kb

input:

50
9157 2
196768 6057 43739 1566 150378 143252 131404 59006 3393 120154 90789 84148 18826 18455 260083 10128 65751 185720 267739 189940 331251 324002 312924 97377 72708 14078 28933 307096 5504 120380 162507 200204 322648 121169 93443 35639 319034 181841 29644 97702 180344 35600 72917 212888 3118 814...

output:

499856159447743091
499758191875828865
499305867415143566
499868365700484880
499886372489761224
499698424306275760
499430251018975854
499869934136230127
499874132032087455
499596824270460331
499855357033100328
499658386014004984
499819928038891147
499853084063175794
499882602677083321
499790928044704...

result:

ok 50 numbers

Test #19:

score: 0
Accepted
time: 43ms
memory: 3804kb

input:

50
9639 3
64362 33964 306873 167532 9099 74702 9493 86317 79697 47339 222822 403441 162498 118514 108099 75729 69215 274522 799909 44142 223974 132126 140545 57350 11314 31845 32110 17620 344090 110432 75265 214647 62793 97704 4630 109512 46165 21246 7647 111792 32924 121123 50749 116520 66290 80389...

output:

2405087768938
2334294156906
2389747951478
2294454202731
2268092300953
2469929722683
2296007842250
2280273036483
2391724788815
2284726727867
2437215625650
2283366669042
2400154541298
2368169733071
2279532163987
2392917851510
2493658737222
2326260251596
2294362158102
2502888161144
2391172784649
238095...

result:

ok 50 numbers

Test #20:

score: 0
Accepted
time: 45ms
memory: 3920kb

input:

5
97065 1
6944 7864 4170 2135 5213 6067 6232 8951 6490 16147 25171 18708 2274 1219 25567 9738 314 7578 2973 8692 5627 158 1260 932 18380 16483 8828 7163 105 3882 4782 18418 20 515 3296 8700 942 14061 8628 15897 3427 1844 31643 7125 5862 2344 131 2435 7441 17496 2736 10267 7376 23012 1225 7137 332 26...

output:

499995807508788528
499976710771200405
499997759502509920
499995127511870628
499987413579209991

result:

ok 5 number(s): "499995807508788528 49997671077...127511870628 499987413579209991"

Test #21:

score: 0
Accepted
time: 46ms
memory: 4200kb

input:

5
94292 2
2567 5868 11887 9577 16682 12360 26361 12345 15380 1586 1068 11703 6815 10719 7508 2823 54277 6105 5745 17569 684 1117 17252 10441 135 5072 1352 19172 2356 4541 8843 12722 4845 23072 7377 60 35156 21277 2355 15551 30236 3299 677 1811 6700 13878 1477 16672 3482 1744 29724 14733 11616 9425 3...

output:

499978343017109446
499987324856156439
499987972212187674
499985489931040147
499969369291534979

result:

ok 5 number(s): "499978343017109446 49998732485...489931040147 499969369291534979"

Test #22:

score: 0
Accepted
time: 43ms
memory: 3940kb

input:

5
93672 3
1146 2761 1220 12295 33553 1459 30111 4261 8142 10550 6227 6350 28945 20704 2943 5267 3443 6514 4810 3134 1455 7960 14898 11780 13060 9937 15605 6322 871 5889 9553 5161 615 24157 1449 3860 19644 5325 21340 17974 5725 31993 7336 72 12665 5352 20445 27036 4269 21812 3999 3970 1402 3492 752 7...

output:

23451178155241
23102048586377
24978920212119
22980641632353
22730030673234

result:

ok 5 number(s): "23451178155241 23102048586377 ...9 22980641632353 22730030673234"

Test #23:

score: 0
Accepted
time: 40ms
memory: 4868kb

input:

1
474171 1
3035 849 206 1943 1449 1041 1968 2047 21 3638 9844 352 4306 6853 277 1218 474 10659 1007 141 2787 2586 930 2823 8050 11819 2557 160 3482 1968 3425 192 132 3411 6357 3347 4108 1823 121 7442 110 6321 2177 3552 118 831 1173 139 1087 5885 1414 117 100 2073 8098 2948 1361 3717 2954 2814 4734 5...

output:

499999870500008385

result:

ok 1 number(s): "499999870500008385"

Test #24:

score: 0
Accepted
time: 45ms
memory: 4896kb

input:

1
493122 2
812 1479 877 316 1849 2356 2382 904 4415 3465 668 1631 2722 558 7576 4766 5729 1706 1481 1727 2632 1099 180 1878 4312 2292 787 2944 1543 2260 1360 129 477 1191 3135 110 2257 679 713 5674 1396 1668 668 2947 960 2674 732 7421 4782 134 3248 155 230 1131 2800 405 1333 50 2344 469 1638 757 130...

output:

499997494855239178

result:

ok 1 number(s): "499997494855239178"

Test #25:

score: 0
Accepted
time: 42ms
memory: 5076kb

input:

1
493464 3
538 9217 697 2032 1590 9897 2234 1122 1454 8570 207 2956 2589 2318 162 1934 1792 20 1019 2319 88 2443 814 123 2260 652 4096 210 1272 1369 1867 1496 1606 3832 546 1914 1760 3335 1297 8069 2329 5806 288 211 278 81 1688 5197 11003 1295 410 1164 679 2225 3859 1680 627 407 2392 152 2862 501 39...

output:

123513184602330

result:

ok 1 number(s): "123513184602330"

Extra Test:

score: 0
Extra Test Passed