QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317123#8169. R-Connected ComponentsqiuzxWA 7ms3716kbC++171.0kb2024-01-28 15:46:112024-01-28 15:46:11

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
3

output:

1
2
inf

result:

ok 3 tokens

Test #2:

score: 0
Accepted
time: 5ms
memory: 3680kb

input:

100
971962039
377418539
436722941
974460973
408831757
674955527
838941797
566099869
224191573
85539073
544795513
157335071
243499759
907206901
570172403
871918511
594778897
773009569
9371917
23810669
169348601
804358351
78636461
382633897
182514781
846151963
274168729
929192339
91532527
172531889
18...

output:

inf
inf
1
1
1
inf
1
1
1
1
1
inf
inf
1
inf
inf
1
1
1
1
1
inf
1
1
1
inf
1
inf
inf
1
inf
inf
inf
inf
1
inf
inf
inf
1
inf
inf
inf
inf
inf
1
1
inf
inf
1
1
inf
inf
1
1
inf
inf
inf
inf
inf
1
1
inf
inf
1
1
inf
1
1
1
1
inf
inf
1
inf
inf
inf
inf
inf
1
1
1
1
inf
1
1
1
inf
inf
1
inf
inf
1
inf
1
inf
1
1
inf
inf
1

result:

ok 100 tokens

Test #3:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

100
145332973
48696341
806778307
222052531
641666023
541840597
635341691
814013
661659811
428891707
81656189
417810353
889550023
634550447
905470561
429756883
249889429
195597113
906475553
913878767
953103803
192400903
483162293
643055177
137120771
748444841
701614733
452585411
367582519
564268909
6...

output:

1
1
inf
inf
inf
1
inf
1
inf
inf
1
1
inf
inf
1
inf
1
1
1
inf
inf
inf
1
1
inf
1
1
inf
inf
1
inf
inf
1
1
inf
1
1
1
1
inf
1
1
inf
1
inf
1
inf
inf
inf
1
inf
1
inf
inf
inf
inf
inf
1
inf
inf
1
1
inf
1
inf
1
1
inf
inf
1
inf
inf
inf
1
1
inf
1
1
inf
inf
inf
inf
1
1
1
1
inf
inf
inf
1
1
1
inf
1
inf
inf
1
1
1
inf

result:

ok 100 tokens

Test #4:

score: 0
Accepted
time: 7ms
memory: 3712kb

input:

100
999999937
999999929
999999893
999999883
999999797
999999761
999999757
999999751
999999739
999999733
999999677
999999667
999999613
999999607
999999599
999999587
999999541
999999527
999999503
999999491
999999487
999999433
999999391
999999353
999999337
999999323
999999229
999999223
999999197
999999...

output:

1
1
1
inf
1
1
1
inf
inf
1
1
inf
1
inf
inf
inf
1
inf
inf
inf
inf
1
inf
1
1
inf
1
inf
1
1
inf
1
inf
inf
1
inf
1
inf
inf
inf
inf
inf
1
1
1
1
inf
inf
1
1
1
1
inf
1
inf
inf
1
1
1
1
1
inf
inf
inf
1
1
inf
inf
1
1
1
inf
1
1
1
inf
1
inf
inf
1
inf
1
1
1
inf
inf
inf
1
inf
inf
1
1
inf
inf
1
inf
inf
1
inf
inf

result:

ok 100 tokens

Test #5:

score: 0
Accepted
time: 3ms
memory: 3592kb

input:

100
315798823
138076441
16013527
105333433
88400579
81370909
61828003
35409677
1148723
553787863
27501853
362120687
51345997
55496489
317656091
244618859
93709579
179950021
391542071
892937473
51911033
520441661
257008447
808078441
9461321
313593769
230895449
409677377
957316117
263495411
185463989
...

output:

inf
inf
inf
1
inf
inf
inf
1
inf
inf
inf
inf
1
1
inf
inf
inf
inf
inf
inf
1
inf
inf
1
inf
inf
1
1
1
inf
inf
inf
1
inf
inf
inf
inf
inf
1
inf
inf
inf
1
1
inf
1
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
1
inf
1
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
...

result:

ok 100 tokens

Test #6:

score: 0
Accepted
time: 4ms
memory: 3592kb

input:

100
33396841
155925169
725337061
54724081
120942061
666015877
383161
901555513
883456729
24196561
743043373
12241
73396613
329229533
416642297
284838833
539493529
231009601
832841881
143815537
223173721
265406201
236882881
22071701
163814401
90810781
563712997
528397937
113699569
388557821
19246817
...

output:

33396841
155925169
1
1
1
1
383161
1
883456729
24196561
1
1
1
1
1
1
539493529
231009601
832841881
1
223173721
1
236882881
1
163814401
1
1
1
113699569
1
1
1
1
389628121
1
1
1
1
1
1
848615161
101586241
516961
161366209
1
85137529
1
1
541911841
40436881
734789449
10004569
1
1
858665809
961
633579241
1
1...

result:

ok 100 tokens

Test #7:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

100
499658057
36899
6949
37019
984462473
106816361
1
1
22543
26953
2579
36913
257
1
716290573
149499529
20681
85306069
674566037
979891873
37321
373483237
1
609923317
1
3697
381941449
1
11909
27527
32851963
1
1
994521181
404960503
412873481
25229
31649
1
1
560316241
648138649
68383457
269359861
9144...

output:

1
inf
1
inf
1
1
1
1
inf
1
inf
1
1
1
1
149499529
1
1
1
1
1
1
1
1
1
1
1
1
1
inf
inf
1
1
1
inf
1
1
1
1
1
560316241
1
1
1
1
1
inf
1
inf
1
1
1
1
1
863360689
1
inf
inf
inf
140161921
1
1
1
1
1
1
1
inf
1
1
inf
1
1
1
1
1
1
1
1
inf
inf
57121
1
1
1
inf
1
1
1
1
1
1
1
1
1
1
1
343694521
1
1

result:

ok 100 tokens

Test #8:

score: 0
Accepted
time: 4ms
memory: 3648kb

input:

100
187975087
276217093
379657199
19605367
26780417
115587119
822088937
707592463
138222697
208471433
554801549
117467881
424963307
460625467
941301527
46982561
496089131
195270919
418619423
4244843
680028269
472729021
208491079
9537223
499139983
613552127
112408841
457474711
975931039
330137651
766...

output:

inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
1
1
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
in...

result:

ok 100 tokens

Test #9:

score: 0
Accepted
time: 3ms
memory: 3596kb

input:

100
926045761
14670797
171688609
6446521
16737737
574909381
373909561
547799737
518254321
127667401
20163653
475166101
497423809
27789353
146010829
203374313
964909969
109390681
852531377
743288509
521410829
146539061
11015761
104919049
74658329
832009333
25253
275659609
9661
436984357
438641981
292...

output:

926045761
1
171688609
6446521
961
1
1
1
1
127667401
1
1
497423809
1
1
1
964909969
109390681
1
1
1
1
11015761
104919049
1
1
1
275659609
1
1
1
292375801
1
1
143641
177608929
173159281
562590961
173475241
63218401
1
1
1
570588769
104509729
1
1
935089
130484929
1
1
1
1
597460249
325549849
1
1
1
3481
273...

result:

ok 100 tokens

Test #10:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

100
26713
263648797
137334961
32321
29333
17957
74605217
258427909
879778901
360802447
641367061
542799073
27743
688340633
417761737
1
288847913
566928841
1
24373
31489
328528741
487071331
29209
262454497
823802533
33029
17417
12953
1193
38431
14827
24137
31321
666705601
1
22381
508641857
230597681
...

output:

1
1
137334961
1
1
1
1
1
1
inf
1
1
inf
1
1
1
1
1
1
1
1
1
inf
1
1
1
1
1
1
1
inf
inf
1
1
1
1
1
1
1
1
inf
inf
1
1
inf
1
1
1
1
85137529
inf
1
1
1
inf
1
1
1
1
1
1
1
1
inf
1
1
inf
1
1
1
1
1
387577969
1
1
29235649
71284249
1
1
1
inf
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
72982849
1
1
1

result:

ok 100 tokens

Test #11:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

100
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991
999999990
999999989
999999988
999999987
999999986
999999985
999999984
999999983
999999982
999999981
999999980
999999979
999999978
999999977
999999976
999999975
999999974
999999973
999999972
99999...

output:

512
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
9
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
inf
inf
2
1
inf
inf
inf
inf
inf
inf
18
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
4
inf
98
1
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
...

result:

ok 100 tokens

Test #12:

score: 0
Accepted
time: 5ms
memory: 3652kb

input:

99
299902924
35471594
767706938
205698814
603316556
959029294
669327817
60138672
712708244
210563062
601408116
437250771
158745205
750158779
756779346
816318088
345490794
171471636
393930139
200252253
662551077
930897589
745450774
653627965
689924438
826274515
230872263
483617510
728080890
366788221...

output:

inf
inf
inf
inf
inf
inf
inf
inf
4
inf
36
inf
1
inf
18
inf
inf
inf
inf
inf
inf
1
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
36
inf
121
inf
inf
inf
inf
inf
inf
inf
32
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
16
2
inf
inf
1
inf
inf
inf
i...

result:

ok 99 tokens

Test #13:

score: 0
Accepted
time: 4ms
memory: 3640kb

input:

99
488088308
663690321
268225458
648477948
688846579
254806549
113314121
438995270
56300243
73381809
776283843
251076857
929879954
86940650
209494574
16336790
328610214
342080737
483571163
242283385
803352057
377592875
371617968
4533714
306390527
390527765
576136864
186247299
290383679
400622739
308...

output:

4
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
1
inf
2
inf
inf
inf
1
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
484
inf
2
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
1
inf
inf
inf
2
1
4
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
...

result:

ok 99 tokens

Test #14:

score: 0
Accepted
time: 4ms
memory: 3592kb

input:

97
840202518
671320750
280528584
906366382
287081712
921963495
331419154
411783637
28411034
363506012
200247422
88538940
378604243
190325137
518138314
74408408
509021083
416036599
950895784
975528353
234364739
687930548
333943665
414528753
776199706
685313211
301500175
945316256
814736881
950995223
...

output:

inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
2
inf
inf
inf
8
1
inf
inf
inf
inf
inf
inf
inf
32
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
2
inf
inf
inf
inf
inf
inf
72
inf
2
inf
inf
inf
inf
9
inf
inf
8
inf
2
inf
inf
...

result:

ok 97 tokens

Test #15:

score: 0
Accepted
time: 4ms
memory: 3656kb

input:

96
929503810
150629471
302391255
35506390
226176149
394943615
380793606
668719155
109471389
573877275
471827746
986995188
677912717
357512231
525712669
102198307
122271417
316947200
655536963
938366792
884425402
749922216
99452382
894325929
324632943
546176203
110264722
448468150
705421788
345896691...

output:

2
inf
inf
inf
1
inf
inf
inf
inf
inf
2
inf
inf
inf
1
inf
inf
inf
inf
inf
98
inf
inf
inf
inf
inf
2
inf
inf
inf
2
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
36
inf
inf
inf
4
inf
inf
inf
inf
8
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
576
inf
1
inf
inf
inf
inf
inf
inf
inf
4
1
inf
inf
inf
inf
in...

result:

ok 96 tokens

Test #16:

score: 0
Accepted
time: 4ms
memory: 3712kb

input:

87
628640451
418894147
127415700
460391125
748700143
947553400
336114946
589685593
560604405
147529680
941694657
241136656
604410904
384716420
350195802
677186930
39772698
559195055
154207794
130703534
459402160
386402858
807221542
536095345
303589229
568841882
596276334
242257576
996431662
91391563...

output:

inf
inf
inf
1
inf
inf
2
inf
inf
inf
inf
16
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
98
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
1
inf
inf
1
inf
inf
2
4
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
inf
1
in...

result:

ok 87 tokens

Test #17:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

99
9210919
66487
45363
267802819
904496086
78824728
21340
8113170
754973
92571
4407
527278
117602
303673
2056
762965757
98287554
888213030
301318559
16248
743065245
56952179
13440560
142741696
425761
7765
698357690
846268971
41934076
41301225
13052514
8581028
40800235
98382
64498631
621956479
715994...

output:

inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
8
inf
inf
inf
inf
inf
inf
inf
inf
inf
49
1
2
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
16
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
2
2
inf
inf
inf
inf
inf
1
inf
1
8
inf
inf
in...

result:

ok 99 tokens

Test #18:

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

input:

94
6976
1293
801978
1681
62802181
8598582
7258
54144902
55033
57437
420025242
90802
31159335
43770
6633
68109
835278
158039
576483
84343980
45391
538292706
2987664
68271
52615
383157
264968419
328398366
7868
6271720
53910
304167
9390906
97523
3614
15455878
31216337
4505817
73497354
8920
365041714
36...

output:

64
inf
inf
1
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
2
inf
inf
98
inf
inf
inf
inf
inf
inf
inf
1
1
inf
inf
inf
inf
1
inf
inf
inf
1
2
inf
inf
inf
2
inf
inf
18
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
i...

result:

ok 94 tokens

Test #19:

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

input:

84
660688
20674292
2187
9475022
408701
29846
4478
42964
759085654
424454
35518911
53408
82279
89236112
6311
308556
261158
6384
155687414
83386
692254788
55845413
740198808
586059370
852760310
2017
41539
3598101
289897
12616
727452
42718737
349484
63893
2019
4247786
46413491
136433564
9680
4989
89172...

output:

inf
4
inf
inf
1
inf
inf
inf
inf
inf
inf
32
inf
inf
inf
inf
inf
inf
inf
2
inf
1
inf
inf
inf
1
inf
inf
1
inf
inf
inf
inf
1
inf
inf
inf
inf
1936
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
inf
8
inf
inf
inf
inf
inf
inf
inf
9
inf
inf
inf
inf
inf
inf
inf
inf
18
inf
inf
inf
inf
inf
inf
inf
inf
i...

result:

ok 84 tokens

Test #20:

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

input:

85
921010
4418
49090
80599
8823
4013
58596213
6573
363995431
2579417
915708
27655419
72901
81744
77936
19999823
9157307
840946
2715
909856
14642273
397708
84696
273976897
4441905
574917263
400826798
9495
680177
3721
5404369
428606705
5095624
62471
1590
3863
734484
15421451
787709
390871
88590976
970...

output:

inf
4418
2
inf
inf
1
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
2
inf
32
1
inf
inf
inf
inf
inf
inf
inf
1
1
inf
inf
8
inf
inf
inf
inf
inf
inf
inf
128
1
inf
inf
inf
inf
inf
inf
inf
1
49
inf
1
inf
inf
inf
inf
inf
inf
inf
inf
1
inf
inf
inf
inf
4
inf
inf
inf
inf
inf
inf
inf
inf
inf
2
inf
inf
inf
inf
inf
i...

result:

ok 85 tokens

Test #21:

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

input:

84
535423
93379
37472
370928
59818286
41683494
2097746
532886
11243
9469
2715092
60005
940517553
6551758
1633
8794731
2573378
82602964
94910701
42461
10408
9111
647526605
8591
769179
12743084
1666
125964916
73014948
5565
954233
85913
61131457
9650152
444136
7142623
566243
7144640
244440518
3120695
4...

output:

inf
inf
inf
inf
inf
inf
inf
inf
inf
1
4
inf
inf
inf
inf
inf
inf
4
1
1
8
inf
inf
inf
inf
inf
98
inf
inf
inf
inf
1
inf
8
inf
inf
inf
inf
inf
inf
inf
4
2
inf
2
9
inf
inf
inf
4
1
inf
inf
inf
inf
2
inf
2
inf
inf
inf
inf
inf
inf
inf
98
inf
inf
inf
inf
inf
inf
1
2
inf
inf
inf
4
inf
inf
inf
inf
inf
inf

result:

ok 84 tokens

Test #22:

score: -100
Wrong Answer
time: 0ms
memory: 3604kb

input:

100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

output:

1
2
inf
4
1
inf
inf
8
9
2
inf
inf
1
inf
inf
16
1
18
inf
4
inf
inf
inf
inf
1
2
inf
inf
1
inf
inf
32
inf
2
inf
36
1
inf
inf
8
1
inf
inf
inf
9
inf
inf
inf
49
50
inf
4
1
inf
inf
inf
inf
2
inf
inf
1
inf
inf
64
1
inf
inf
4
inf
inf
inf
72
1
2
inf
inf
inf
inf
inf
16
81
2
inf
inf
1
inf
inf
inf
1
18
inf
inf
i...

result:

wrong answer 50th words differ - expected: '2', found: '50'