QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#880814#10021. Interesting PermutationsUndercover#AC ✓3110ms170960kbC++234.7kb2025-02-03 21:03:332025-02-03 21:03:34

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2390ms
memory: 170680kb

input:

2 4
4 1 3
3 1 1
9 3 7
1 1 1

output:

16
2
27160
1

result:

ok 4 number(s): "16 2 27160 1"

Test #2:

score: 0
Accepted
time: 2346ms
memory: 170812kb

input:

256 2
3 1 2
65536 1024 32768

output:

4
517264494

result:

ok 2 number(s): "4 517264494"

Test #3:

score: 0
Accepted
time: 2682ms
memory: 170812kb

input:

1 200000
99995 1 99995
86918 58999 70159
38506 19694 35974
61868 23700 48472
96263 21196 92667
36991 3780 9438
77068 4731 6756
91757 16570 17799
94328 32908 45275
96221 14327 73644
31545 3936 13527
75467 39216 53147
6504 3883 4018
44965 11765 21601
45895 906 15282
8325 977 5431
48153 35761 40406
974...

output:

819483871
13936401
546075692
56537597
518171841
682765317
946113420
111175382
527234083
884763597
215402563
461077254
49673662
300376005
120226240
844876192
638718737
11806698
960129878
223144195
848075741
521696018
957550193
62225566
854778724
728165545
839086009
308408176
495281237
923053738
66607...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 2640ms
memory: 170808kb

input:

2 200000
99998 1 99998
14942 12835 14504
78337 14540 77264
40774 2149 5224
72834 23319 45958
23436 7205 13210
22999 5704 21120
50075 7797 48312
65548 20263 54003
38680 35258 35385
958 125 847
86462 57304 59001
13524 7735 10332
24825 4026 10613
77597 42777 60649
46561 41783 43903
57260 14800 45333
79...

output:

593638678
894905611
808484409
109484973
494854190
581276152
218322644
765497988
731898637
571661575
612587162
305378873
925139743
410143855
396930849
771876259
405448963
18985906
778342456
423902336
504843547
448841219
370446285
806431564
653687000
635238016
949045302
646728146
47297767
541560409
71...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 2740ms
memory: 170816kb

input:

3 200000
99998 1 99998
79089 38062 70225
16287 6313 11810
11626 4897 6162
30908 6805 7969
51968 7604 47840
95655 93430 93696
40159 19951 27848
66589 42415 61700
67337 1817 24633
93671 6405 31948
55798 17805 29237
87579 31282 56392
68465 26379 42636
45046 31137 36834
3023 1072 2282
15319 14105 14691
...

output:

272184092
490302289
693226832
818893049
661495133
692471611
93104236
933120595
911015708
21124979
332787868
864062226
15790439
780715997
435136774
557127791
723051063
223892080
177657330
953405498
415965440
160709439
644690098
261001437
18565111
85461772
156778283
42075254
374347304
662185953
317581...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 2940ms
memory: 170916kb

input:

98 200000
100000 1 100000
6502 2213 2935
53997 42038 43908
68958 14314 53993
93884 68506 93377
82405 10861 21708
23366 7085 20254
93187 24336 32214
20435 10610 14280
55096 24827 28554
1180 778 1085
88284 27689 52452
31269 3094 22525
97557 3746 53743
18040 3031 10427
74201 6458 44896
45123 31566 3208...

output:

299469104
412714187
706251591
498995824
849518690
594078846
1137706
886819963
305659464
340273458
447425568
903159307
20895823
307953373
607502478
363101515
319966746
28185723
953301165
497818789
673036729
400321040
63543866
225938391
137232717
340210343
956434579
237992806
785603788
403720719
96079...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 2657ms
memory: 170812kb

input:

500 200000
99997 1 99997
78213 33719 64821
1396 1047 1395
14412 9659 14031
74860 55275 64135
55715 28404 50067
7386 607 6964
34958 5992 15255
2934 51 1363
93454 2236 92241
38405 754 10470
73751 13138 15100
51258 1006 14307
25070 7424 18428
5324 3084 5227
22918 16101 21684
51320 38369 48987
26684 111...

output:

252778910
111426105
701583307
553569963
387775892
511901999
541643031
970331194
205083058
802113386
604856794
657158366
780477337
105521047
57724931
418848968
798604108
354526444
278085490
625641342
599735846
322012815
155451652
615915800
856322456
713579183
807993503
265439383
383115889
426203484
9...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 2682ms
memory: 170812kb

input:

100000 200000
99998 1 99998
96151 32977 91203
60890 2251 35995
20635 2141 3071
55922 2510 18019
98176 4442 88869
52460 4447 29495
12137 7559 10840
98573 44540 83623
97746 11584 25007
36426 2873 14990
24943 12719 18809
16993 9201 13141
97443 6338 46858
34298 5432 9018
59839 11729 48921
98430 13985 79...

output:

841597075
711844320
3872626
258971814
916448182
376902454
214439846
516524667
12565462
593343986
765301233
289360957
973382368
682581353
540350170
404545418
487350501
223973170
978756180
43702310
852725195
348294897
373661231
110467120
660467574
88219309
77591540
516259330
294771966
876754578
458250...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 2820ms
memory: 170812kb

input:

99757 200000
76726 28599 64201
82850 34021 39073
29863 8203 23904
35988 11985 12593
43319 27500 38958
78278 12475 25225
17700 11627 17338
56346 7288 54424
9346 7674 7988
90029 25396 47454
62354 26629 38409
69069 40723 62184
10371 1581 5929
68732 31729 68727
28969 13819 21057
19562 7882 12799
13436 6...

output:

486097848
395462401
22697306
295824305
77033503
580200446
353406119
720973639
82928165
642604900
580203461
423966990
921604386
844060922
300227104
535787881
272034989
95161174
177863751
146282542
134251145
887575107
216955145
629132849
719201063
261579247
617938635
61401190
393884824
683038214
98998...

result:

ok 200000 numbers

Test #10:

score: 0
Accepted
time: 2702ms
memory: 170808kb

input:

70260 200000
89582 23838 62054
87607 46903 83341
10588 6256 6429
56067 7208 40950
52354 3626 9997
48338 6996 6996
39490 8872 35167
53320 27943 37587
48678 19442 42927
28514 19261 21644
83066 10407 34659
79096 58695 66506
79715 57047 72719
13361 4654 8311
1861 660 1119
5735 1841 4859
10516 1785 8504
...

output:

23955255
620741283
68596072
460366249
95487260
533838805
959213626
744109917
18289245
183238836
925206658
243300028
744849799
431038711
601084016
241367515
826042638
533923360
337957585
35030172
806921808
309034488
333789951
312306939
476861506
491666243
56741363
134930767
769379137
858380965
340105...

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 2654ms
memory: 170684kb

input:

76029 200000
44048 4683 15494
51202 20518 34418
55059 9655 33866
3940 489 1814
48515 14544 25640
48597 31329 37614
38418 16891 34174
29927 2996 29208
7028 305 1685
90236 38139 70369
19942 6018 6108
65406 11798 57390
26238 12401 18496
67709 50182 55137
68531 37959 53488
47144 37498 40444
86384 9265 7...

output:

136831200
184041279
78599309
197939476
196533215
742722055
866142064
437755777
593338014
259483989
865540968
177783133
953417820
564725643
995708543
88083321
73621656
417977087
904042570
143703647
995508938
645011851
255365073
321399044
837487761
887154556
186005737
421500786
501036041
627812493
213...

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 2661ms
memory: 170816kb

input:

86508 200000
87534 9886 14476
75656 44553 58084
35 12 26
64612 21802 28652
15936 2879 5724
80769 52539 56397
17248 8644 13985
63468 34993 37935
40247 11944 28887
33758 12831 14041
39244 11345 26887
92285 9573 57891
87769 7836 71217
33206 16610 32989
37829 2913 28674
81784 550 80281
84927 54784 58806...

output:

414798745
836413601
173142698
19429822
341878514
274026325
350576270
206150375
807679601
773485637
838674732
765095468
294225636
746738748
502691349
651257222
168991858
992447013
781966178
178994065
730889359
389316866
806038404
798179478
751609084
421880807
536705767
347429113
435105191
522445774
3...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 2641ms
memory: 170812kb

input:

94887 200000
41580 26124 31456
54015 6509 42800
19490 7897 7933
23003 4742 14753
5656 547 5624
73865 71253 73021
37578 11230 30606
85420 22438 60018
62701 2647 24572
5927 2177 2672
3055 275 1858
66296 45668 52410
37233 1551 27036
1754 331 1327
78724 9595 22604
32283 23567 25470
92067 3662 55730
5336...

output:

770402473
408968490
318327293
929442170
700705356
789583372
78022634
236251745
721359327
774082769
448475859
116261800
15120145
202325787
22935809
203424122
803629556
395090039
319381839
272744470
996170780
571943210
37350692
151227599
641165632
727572155
326493923
150460832
751074441
247521695
6907...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 3110ms
memory: 170956kb

input:

16194 200000
72886 1 72886
8516 1 8516
88928 1 88928
83229 1 83229
99413 1 99413
80348 1 80348
34640 1 34640
89368 1 89368
49346 1 49346
12227 1 12227
18122 1 18122
47967 1 47967
34730 1 34730
93969 1 93969
52758 1 52758
58964 1 58964
43533 1 43533
75663 1 75663
52013 1 52013
13354 1 13354
7139 1 71...

output:

886959128
506083993
218488598
438649157
85271713
721909951
297373797
220801175
764073892
407745691
803342013
56121715
426674810
40459469
538262952
180010139
301467757
823169542
773949565
772016689
95553041
500817318
599561674
587816650
719419296
662280286
278305040
614870049
10532787
265578187
19623...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 2864ms
memory: 170680kb

input:

88679 200000
26685 1 26685
78703 1 78703
2167 1 2167
41307 1 41307
57476 1 57476
14061 1 14061
42402 1 42402
8511 1 8511
12748 1 12748
58775 1 58775
84299 1 84299
63807 1 63807
23117 1 23117
22420 1 22420
94996 1 94996
48701 1 48701
95184 1 95184
82111 1 82111
98160 1 98160
63695 1 63695
73845 1 738...

output:

744465585
903811408
208637738
551137364
895592699
883849202
643789682
340223968
846411138
731679638
450251132
481326457
717309008
248603776
363257982
660911076
667840719
628530326
214897144
288740131
18529063
700588693
796146779
745856888
25196400
803240403
606640234
995092549
236915703
133201328
10...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 2921ms
memory: 170688kb

input:

5899 200000
72155 1 72155
9974 1 9974
26350 1 26350
83873 1 83873
18567 1 18567
70449 1 70449
46984 1 46984
27050 1 27050
3905 1 3905
32925 1 32925
81153 1 81153
73182 1 73182
71983 1 71983
49753 1 49753
20218 1 20218
10374 1 10374
57230 1 57230
10139 1 10139
98248 1 98248
82178 1 82178
95277 1 9527...

output:

29653526
152113609
15076201
436293654
651280706
945228827
509295516
482887613
468016305
375648734
170553096
262685277
219807673
573135446
337119795
351475979
564327700
460330577
226576212
2656618
963391690
810742037
286628921
659479493
889086192
754523469
47868181
440292618
740938994
682723910
88500...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 2906ms
memory: 170816kb

input:

22149 200000
72346 1 72346
26414 1 26414
34515 1 34515
98302 1 98302
3270 1 3270
35743 1 35743
99965 1 99965
7463 1 7463
17907 1 17907
23664 1 23664
20324 1 20324
81031 1 81031
28196 1 28196
57539 1 57539
20881 1 20881
16473 1 16473
34604 1 34604
83727 1 83727
87492 1 87492
30766 1 30766
38868 1 388...

output:

534160978
132224864
772802330
522167418
833060939
892628476
575939549
317646851
687872308
856726727
975664199
597001216
915092648
939171103
391791844
380271612
537971467
347073561
764522868
783399367
598988889
8648490
212638723
958090890
526079743
417270213
785080701
348456996
224891271
879412833
41...

result:

ok 200000 numbers

Test #18:

score: 0
Accepted
time: 2633ms
memory: 170816kb

input:

1 200000
99986 30264 80431
99162 4089 54558
99102 26347 76832
99446 7500 56948
99903 38449 87547
99019 25034 74190
99432 45646 95585
99588 1529 52374
99878 33473 82577
99814 14883 64542
99649 765 50057
99560 43521 92902
99388 34528 85118
99751 5230 55709
99067 19169 69658
99390 14404 64780
99189 715...

output:

535953250
313610499
781058127
240813702
941155358
991139488
502267264
137683456
722245554
393686345
265357947
260963176
340055352
726392677
178157784
300357692
663461186
622893633
733171984
407550418
64137377
928576715
618690996
531758065
36887945
140064737
732923981
678431857
22201030
495731267
812...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 2664ms
memory: 170808kb

input:

2 200000
99650 34348 83406
99019 34571 85530
99215 39164 90001
99663 22468 72238
99972 14592 64236
99412 1070 50944
99144 991 51586
99689 27042 76270
99276 35964 86711
99652 10152 61151
99320 40166 90816
99769 11256 60859
99729 41432 90994
99490 40295 89730
99169 11492 61555
99241 15210 65448
99114 ...

output:

269468433
101575068
308761993
713254780
332412849
475635993
129113286
250175884
188160406
43062
162293344
216411248
11065237
141593352
284547437
840888766
658016663
498298137
511415560
394693028
54193692
441114593
68280104
988909905
602051427
194517538
858075640
909708688
704825166
352520799
8821717...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 2679ms
memory: 170684kb

input:

3 200000
99139 42877 93715
99784 4165 53964
99888 34927 84388
99865 33980 83575
99671 47046 97592
99410 33573 84030
99777 44719 95371
99622 39822 89470
99687 1588 52482
99465 22340 72243
99260 37982 88260
99478 18110 69031
99855 10820 60804
99462 31298 81766
99806 7727 56958
99351 33425 82798
99010 ...

output:

790747618
240411614
309541034
744386952
845823034
785079027
326568532
63126723
552623378
898636207
261397083
936199956
123301382
332233561
649115641
449757387
469198086
146801334
979939449
255062825
816997419
320393766
903314085
15939056
55220148
663652856
871069872
461486185
75015010
506296504
6531...

result:

ok 200000 numbers

Test #21:

score: 0
Accepted
time: 2952ms
memory: 170960kb

input:

98 200000
99335 23508 73066
99963 45563 95262
99209 19633 68662
99383 9267 58605
99549 6611 56455
99314 9848 60522
99235 18088 68057
99446 35703 86568
99844 43515 94223
99264 20327 69903
99420 18435 69323
99155 16826 67325
99724 3234 53268
99993 34191 84219
99897 5560 55807
99213 3009 52767
99184 37...

output:

795948210
453180091
236155763
692561651
778601413
114192285
729083211
907765352
97332770
121891883
246981327
82506790
612035647
194199598
997808499
953588909
213303502
920279183
922338309
341956411
907629468
382962224
595829241
650601458
287424816
149997430
898437343
577071959
631295681
923140158
39...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 2732ms
memory: 170684kb

input:

500 200000
99776 41005 90916
99031 6697 56126
99733 40171 90164
99324 1472 51130
99868 31003 80709
99783 37670 86752
99108 11585 62464
99400 27673 78314
99764 27728 77226
99640 43321 93611
99356 27709 77263
99888 4688 54405
99561 9059 59167
99681 42882 93760
99185 29428 79165
99408 29303 79681
99064...

output:

570533550
190614364
347668934
965567306
981659806
946090151
673949908
792184700
144712861
568382057
842884556
724484188
505409335
684004069
842667606
636624153
373641854
686166891
61517338
400716039
924756470
174805927
180601259
328736583
937820407
386062029
514608820
105568524
409171047
43610507
60...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 2648ms
memory: 170812kb

input:

100000 200000
99401 35869 86444
99459 47624 97306
99294 39087 88797
99751 33571 82725
99735 35463 85408
99597 48685 98387
99890 14517 64632
99845 47050 96825
99891 29376 78856
99436 20659 70795
99458 12631 62078
99934 47620 97092
99371 48397 97717
99403 26979 77789
99634 32214 82811
99279 28323 7851...

output:

371016827
761200987
280766459
906345947
763355290
268166756
557201013
916677187
221356828
980102634
775409460
739189691
611018762
525754884
359890101
487390770
209931752
513941749
889669810
471539266
6880099
547618826
51500224
506180832
501777326
745845076
959783412
595368409
26535652
497636374
2078...

result:

ok 200000 numbers

Test #24:

score: 0
Accepted
time: 2606ms
memory: 170680kb

input:

85471 200000
100000 48806 98409
100000 2255 52073
100000 40043 90450
100000 36481 86046
100000 26884 77157
100000 14828 65434
100000 46752 97558
100000 11259 62214
100000 50060 99428
100000 16787 67159
100000 7457 58116
100000 41185 91190
100000 46375 96343
100000 47590 96716
100000 22199 71349
1000...

output:

591513341
375890228
30514704
981923202
958367095
673247697
767160557
866240366
398230353
981520177
955035148
323940010
702372774
287868844
816730945
411603902
397096002
926454723
815459204
89208111
438075462
623191506
649876975
832601613
440955622
713086176
622992717
300733647
791168885
518845657
14...

result:

ok 200000 numbers

Test #25:

score: 0
Accepted
time: 2680ms
memory: 170812kb

input:

64425 200000
100000 37660 87404
100000 19543 69374
100000 1060 50473
100000 28133 77840
100000 24692 75053
100000 10409 61273
100000 1142 50210
100000 35844 85132
100000 9291 58950
100000 32146 82603
100000 19269 69372
100000 44215 94835
100000 33626 84614
100000 30511 80302
100000 37408 86631
10000...

output:

172523095
831889763
294386133
222072583
298340728
174643679
803380685
411953306
84876901
593979647
94820854
217956975
865699571
125456747
500981851
296128089
363695633
955194892
678407810
630973734
741875220
208614837
39858996
471887406
796600599
338635506
103538825
329918666
292273191
560881672
947...

result:

ok 200000 numbers

Test #26:

score: 0
Accepted
time: 2616ms
memory: 170808kb

input:

13363 200000
100000 36921 86802
100000 20996 71334
100000 41041 90523
100000 26867 76255
100000 22197 71317
100000 27905 78347
100000 17841 68437
100000 15743 66472
100000 34993 85496
100000 39230 88534
100000 5822 56776
100000 3795 54524
100000 5804 55969
100000 48426 97768
100000 43849 93953
10000...

output:

321295774
883644549
774823956
372054556
822863235
756103891
418357395
389773397
430915716
306547136
375293797
187530772
760902532
582424845
423158562
427757364
935038229
125676789
789830367
579721127
363777981
372196204
583339159
199582821
20146425
886396809
914839438
875462939
627656034
990455276
4...

result:

ok 200000 numbers

Test #27:

score: 0
Accepted
time: 2666ms
memory: 170812kb

input:

84494 200000
100000 16388 66609
100000 7093 57182
100000 23409 74116
100000 3119 52838
100000 1542 52331
100000 3243 53672
100000 37296 86347
100000 36538 86653
100000 5941 55694
100000 222 49536
100000 35924 85054
100000 9997 59511
100000 39756 89600
100000 22309 72030
100000 5285 55545
100000 3076...

output:

250459816
256905541
454869887
903434727
254698724
542149645
838593368
977804517
702288458
762478360
392557544
997037310
25005660
738521636
735025744
805480864
220796590
277145285
717501928
842380199
448851451
921565025
441259958
805840957
329764287
581430468
528753147
397096002
934996373
395620371
6...

result:

ok 200000 numbers