QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687706#6477. Divide and ConquerPetroTarnavskyi#AC ✓153ms39948kbC++232.1kb2024-10-29 20:37:232024-10-29 20:37:24

Judging History

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

  • [2024-10-29 20:37:24]
  • 评测
  • 测评结果:AC
  • 用时:153ms
  • 内存:39948kb
  • [2024-10-29 20:37:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

const int LOG = 17;
const int N = 1 << LOG;

struct Graph
{
	int t = 0;
	int tin[N], tout[N];
	VI g[N];
	
	void addEdge(int a, int b)
	{
		g[a].PB(b);
		g[b].PB(a);
	}
	int up[LOG][N];
	void dfs1(int v, int p)
	{
		up[0][v] = p;
		FOR(i, 0, LOG - 1)
			up[i + 1][v] = up[i][up[i][v]];
		
		tin[v] = t++;
		for(int to : g[v])
			if(to != p)
				dfs1(to, v);
		tout[v] = t++;
	}
	bool isParent(int v, int p)
	{
		return tin[p] <= tin[v] && tout[v] <= tout[p];
	}
	int lca(int u, int v)
	{
		if(isParent(u, v))
			return v;
		
		RFOR(i, LOG, 0)
			if(!isParent(u, up[i][v]))
				v = up[i][v];
		return up[0][v];	
	}
	
	
	int upVal[N];
	int ans2 = 0;
	int ans3 = 0;
	
	void dfs2(int v, int p)
	{
		for(int to : g[v])
		{
			if(to == p)
				continue;
			dfs2(to, v);
			
			if(upVal[to] == 1)
				ans2++;
			if(upVal[to] == 2)
				ans3++;
			
			upVal[v] += upVal[to];	
		}
	}
}G[2];


int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	
	int n;
	cin >> n;
	
	FOR(t, 0, 2)
	{
		FOR(i, 0, n - 1)
		{
			int a, b;
			cin >> a >> b;
			G[t].addEdge(a - 1, b - 1);
		}
	}
	
	int ans2 = 0, ans3 = 0;
	
	FOR(t, 0, 2)
	{
		G[t].dfs1(0, 0);
		
		FOR(a, 0, n)
		{
			for(int b : G[t ^ 1].g[a])
			{
				if(a > b)
					continue;
				int c = G[t].lca(a, b);
				G[t].upVal[a]++;
				G[t].upVal[b]++;
				G[t].upVal[c] -= 2;
				
				
			}
		}
		G[t].dfs2(0, 0);
		ans2 += G[t].ans2;
		ans3 += G[t].ans3;
	}
	if(ans2 != 0)
		cout << "2 " << ans2 / 2 << "\n";
	else
		cout << "3 " << ans3 << "\n";
	
	
	
	
	
	
	
	


	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2 2

result:

ok single line: '2 2'

Test #2:

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

input:

2
1 2
1 2

output:

2 1

result:

ok single line: '2 1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 28292kb

input:

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

output:

3 4

result:

ok single line: '3 4'

Test #4:

score: 0
Accepted
time: 140ms
memory: 39148kb

input:

100000
9493 5282
33782 60014
13427 66022
53400 90051
27271 21695
58162 39095
35026 5165
97219 42355
94904 87438
90192 34037
71640 40374
85991 78705
11673 43240
77786 11834
10794 15239
64198 90760
55638 61858
75295 36405
83548 7595
60980 2594
896 34987
14300 52319
98205 50770
23075 83397
60853 24296
...

output:

3 4

result:

ok single line: '3 4'

Test #5:

score: 0
Accepted
time: 128ms
memory: 38576kb

input:

100000
12086 99911
99241 75298
69594 18172
88066 98598
29063 60406
17529 77575
30479 2326
35746 46921
23854 10741
94246 90921
21674 99607
47976 28074
96919 34802
85678 16348
95283 53640
33740 9482
2243 66913
44713 80278
38773 45780
54364 76256
13041 95402
92346 223
17956 9425
67162 94015
97881 33236...

output:

3 4

result:

ok single line: '3 4'

Test #6:

score: 0
Accepted
time: 94ms
memory: 36272kb

input:

80102
49942 31361
77478 43608
68974 19331
12536 58280
39869 28247
48037 18489
72301 69352
29972 28184
19095 77279
12371 79658
9495 3722
6714 29425
35206 28358
19565 54227
30379 41966
67307 3001
69022 20212
35332 50051
71250 68845
60437 63791
33786 8972
4005 36515
33919 53440
18525 24340
76908 55503
...

output:

2 1

result:

ok single line: '2 1'

Test #7:

score: 0
Accepted
time: 105ms
memory: 36072kb

input:

77933
28569 35955
36447 19985
30261 46666
67011 48218
52436 58538
103 46616
3934 51804
7421 75609
69412 10331
55877 63591
11524 64159
50159 10999
3029 516
28485 12734
31145 68550
67514 8834
74974 48569
25177 34183
27848 4064
64268 59317
11472 51297
62296 16010
13972 14205
73356 50680
58676 34105
284...

output:

3 4

result:

ok single line: '3 4'

Test #8:

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

input:

75763
44582 10364
12233 55568
44015 68187
20260 3726
62754 30707
9442 58169
63404 25094
16502 43370
11260 10166
18034 50239
67861 13534
18013 26889
35472 787
55966 41650
49729 27949
56956 19467
64216 70356
60062 35994
61250 13936
36703 37524
44140 49040
68588 60526
32451 15522
13184 68612
14272 2682...

output:

3 4

result:

ok single line: '3 4'

Test #9:

score: 0
Accepted
time: 99ms
memory: 36244kb

input:

100000
68254 40240
24822 40240
40240 10334
15543 40240
73072 40240
24275 40240
40240 29004
66456 40240
40240 46398
26784 40240
69164 40240
40240 20655
63153 40240
40240 83319
40240 13846
80532 40240
19574 40240
40240 71695
53996 40240
40240 88353
59206 40240
40240 8824
40240 23448
71396 40240
16779 ...

output:

2 65505

result:

ok single line: '2 65505'

Test #10:

score: 0
Accepted
time: 121ms
memory: 39240kb

input:

100000
23016 12058
84337 75378
35342 11044
80418 70432
1367 96474
41963 98727
51876 75071
24384 19974
59934 25760
60101 7237
42117 48046
27447 65696
16025 49070
1807 48728
88089 51413
78086 85010
85214 91653
19068 53970
11036 12388
83374 3239
72970 11330
3359 91238
71175 22013
79853 46146
58515 5261...

output:

2 2

result:

ok single line: '2 2'

Test #11:

score: 0
Accepted
time: 139ms
memory: 39488kb

input:

100000
67035 67458
10874 94360
35120 34376
37286 77423
29676 53596
86169 42673
53872 64383
32360 12934
86812 16385
50082 12676
15506 49582
44699 93506
21930 48645
35548 81862
56251 71100
76665 82102
78423 24971
57148 97564
50743 51612
89014 47045
93517 69699
3736 76263
88995 47857
12884 69984
95888 ...

output:

3 4

result:

ok single line: '3 4'

Test #12:

score: 0
Accepted
time: 65ms
memory: 34412kb

input:

56837
22561 9809
33266 10681
42254 15777
46302 41681
36127 36168
47508 3405
39619 8885
31391 4494
6229 48010
34505 32224
46651 1116
38352 13126
33080 15401
13312 152
37114 14880
53010 19489
34150 53959
11406 45874
5260 36364
31636 34820
36545 23724
54482 55553
28414 46965
52696 32438
27410 40865
250...

output:

3 4

result:

ok single line: '3 4'

Test #13:

score: 0
Accepted
time: 146ms
memory: 39432kb

input:

100000
66908 48903
15376 98733
96769 61779
35020 53071
29107 85590
50637 88791
733 51481
86432 68305
19722 59381
83290 13084
6153 80634
70262 64709
51748 94219
8736 60173
92194 8374
94324 89185
2416 49691
45699 75755
99895 12773
46208 48758
21013 27848
90094 34627
76515 29226
47681 66149
89059 83636...

output:

3 4

result:

ok single line: '3 4'

Test #14:

score: 0
Accepted
time: 130ms
memory: 38824kb

input:

92081
6551 23765
71391 73199
31857 81921
73232 64026
67896 1398
75157 58271
36574 27767
3315 507
90290 24662
52094 35142
79824 22059
59107 44275
88960 91661
25996 84610
61048 67187
13401 73954
56137 5861
33191 5849
48493 46826
62166 60906
71773 81811
27481 2358
16896 71500
64860 38294
45075 57249
82...

output:

3 4

result:

ok single line: '3 4'

Test #15:

score: 0
Accepted
time: 99ms
memory: 37404kb

input:

79665
4111 8437
60664 44894
73432 22845
57733 42491
31313 76914
8555 77062
55820 71830
28838 31482
68541 22635
32205 4772
34915 50655
79159 50500
8734 67301
17926 26557
4932 19101
51784 44666
38340 1784
54608 61099
49227 76774
50326 44858
47950 57335
16652 68416
51526 71843
33835 63100
4223 43897
15...

output:

2 2

result:

ok single line: '2 2'

Test #16:

score: 0
Accepted
time: 92ms
memory: 35868kb

input:

77495
7989 3719
70283 53238
37004 24260
11750 7407
22204 75322
32624 73867
47756 68893
66570 3094
32711 33526
28423 31737
24595 59389
22201 8431
13576 6595
60744 42502
29897 35288
59464 66985
11296 18451
8755 42422
77285 14732
3652 68602
40513 72379
66308 62823
33092 45976
30755 76356
16006 9655
811...

output:

3 38626

result:

ok single line: '3 38626'

Test #17:

score: 0
Accepted
time: 124ms
memory: 39568kb

input:

100000
49420 89960
21418 5767
69008 75387
5179 53154
26157 64869
44629 15966
89189 62545
58651 97232
48177 1679
55869 12741
64181 96309
13771 67701
4934 97446
48430 46842
89852 10374
30759 75016
86180 7503
58322 32956
4887 79785
84798 6838
22305 8131
59850 73461
32506 1836
23668 87920
85215 33237
37...

output:

3 50095

result:

ok single line: '3 50095'

Test #18:

score: 0
Accepted
time: 140ms
memory: 39276kb

input:

100000
6012 31516
44255 3242
46137 71822
34861 80365
79680 69263
66197 63868
18830 29230
9183 81603
55896 60208
99446 58089
25166 97655
47242 3770
89121 93650
17336 2963
22221 4064
91352 16652
79595 68617
46496 8863
90203 89074
39592 43493
13475 81425
58256 32576
81099 91728
41754 31597
50537 19173
...

output:

3 4

result:

ok single line: '3 4'

Test #19:

score: 0
Accepted
time: 137ms
memory: 39948kb

input:

100000
32102 98390
21156 46799
83751 40028
25839 81010
57407 75204
59539 63415
47763 72084
26736 24346
45254 69541
6483 37749
11696 87391
73837 74476
48935 85627
39689 57520
27408 77096
48027 1333
90224 86341
6187 25059
90280 59440
73044 21933
88456 3952
60394 65257
91464 40290
34339 39811
67685 484...

output:

3 4

result:

ok single line: '3 4'

Test #20:

score: 0
Accepted
time: 119ms
memory: 36468kb

input:

100000
10766 61680
53469 88876
12786 17969
95222 31291
75770 62950
32817 454
10724 8755
43465 26582
33668 54529
56687 92951
25833 24731
45302 43430
33485 13737
31360 30560
87102 67522
49129 75069
20675 9767
72442 55571
84978 16513
55068 14736
85564 94707
99133 70
16482 2930
64796 70650
51717 60713
4...

output:

2 35629

result:

ok single line: '2 35629'

Test #21:

score: 0
Accepted
time: 88ms
memory: 34668kb

input:

80102
42210 70383
43822 66710
34385 4386
23427 27893
29894 38247
42529 67559
28681 59212
3694 36166
52200 75411
53705 77952
13854 41236
17869 26233
10819 49502
57748 43993
50435 19651
30241 76405
27576 10964
66125 36470
25646 63217
57659 12347
51763 66166
58146 37208
1217 143
9832 68931
62943 55593
...

output:

2 20085

result:

ok single line: '2 20085'

Test #22:

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

input:

77933
68458 62877
38774 68458
68458 71012
68458 10645
68458 32530
68458 53938
68458 26679
65659 68458
68458 40335
73016 68458
21847 68458
68458 33573
68458 30013
68458 37640
44442 68458
68458 36728
68458 67641
68458 28529
25142 68458
21483 68458
68458 76813
50656 68458
16713 68458
8683 68458
68458 7...

output:

2 77931

result:

ok single line: '2 77931'

Test #23:

score: 0
Accepted
time: 97ms
memory: 36964kb

input:

75763
10736 73110
13538 64505
56059 2682
30241 5016
14946 7458
61811 33907
70436 63677
75328 24148
25657 20475
6666 22752
59541 54662
41308 10560
40279 56872
468 3945
2192 33206
53240 19314
56444 70432
62083 37748
44339 73090
23855 2742
14336 30374
64609 29576
62774 50802
11557 35005
2655 23577
3014...

output:

3 4

result:

ok single line: '3 4'

Test #24:

score: 0
Accepted
time: 143ms
memory: 39788kb

input:

100000
65138 10481
9827 88277
58381 25955
80944 16420
75281 78840
24688 67564
71262 22501
54278 16321
88614 82876
29607 26022
63708 36732
70723 64878
56572 57221
73954 56540
68900 68769
67246 42495
29479 46900
35768 72457
8276 40931
40094 76029
85962 74988
63333 69280
91717 9052
10431 63327
8915 834...

output:

3 4

result:

ok single line: '3 4'

Test #25:

score: 0
Accepted
time: 113ms
memory: 36388kb

input:

100000
90185 3629
52028 70047
48314 26046
79722 97447
76809 41474
5713 42898
53450 43068
41832 90305
96710 27162
47501 35367
66245 5484
73588 79962
73918 46840
50299 28027
56915 4633
84701 97010
30580 48359
77339 20281
40688 8127
90700 89309
27659 23451
22525 7406
53692 19782
43088 88685
81599 31039...

output:

2 35547

result:

ok single line: '2 35547'

Test #26:

score: 0
Accepted
time: 134ms
memory: 38584kb

input:

100000
78721 48847
46035 27547
64220 28358
57229 11161
60577 32827
83785 2425
29278 71219
65473 1395
87591 33156
62567 39839
55690 14174
73164 43526
24520 59336
50082 64533
43056 66191
58588 46169
81354 37035
43978 87619
95001 56912
12172 64525
15762 78802
52012 2412
28161 97086
84880 30956
11029 90...

output:

2 99999

result:

ok single line: '2 99999'

Test #27:

score: 0
Accepted
time: 141ms
memory: 36984kb

input:

100000
15128 59890
9985 20826
61298 28322
25102 60263
71450 46947
58446 17051
56500 98003
69359 59298
69876 85182
61990 42952
47742 49119
94377 60128
6344 25136
13809 32684
58370 4496
86427 24720
66990 92514
43355 29970
46836 5920
15292 49489
98266 50916
61814 2392
94933 35399
2623 69984
81740 79586...

output:

2 7419

result:

ok single line: '2 7419'

Test #28:

score: 0
Accepted
time: 104ms
memory: 34900kb

input:

80102
2420 52317
7007 13196
40044 31715
40873 4462
3908 28955
77071 27848
29922 51223
11872 11297
77155 45198
67417 49160
61544 68327
10476 17580
52159 8202
32276 5064
55975 58222
4487 13549
75931 72755
27448 42178
38711 50756
77641 70581
38325 9886
56391 58380
15591 66493
19226 38286
76027 74758
57...

output:

2 6039

result:

ok single line: '2 6039'

Test #29:

score: 0
Accepted
time: 90ms
memory: 34604kb

input:

77933
34011 17192
71273 44220
13792 76365
21576 30783
47112 41490
41306 77924
52101 47811
75713 77888
74294 61427
43773 5598
69073 45464
42390 35148
23810 54625
68031 21624
45361 47432
2069 64610
16865 1004
70134 77230
31956 43577
14565 39101
41783 42962
21561 61428
12042 2586
9190 14136
47738 54561...

output:

2 39793

result:

ok single line: '2 39793'

Test #30:

score: 0
Accepted
time: 90ms
memory: 35708kb

input:

75763
21082 11002
8580 34945
13730 7566
53159 58789
25727 64181
32069 29703
69623 31593
36155 16699
27240 53979
43081 51961
4725 64099
45870 22494
70975 53165
24307 74979
45677 72414
54008 53934
14336 72104
60595 64764
22555 66129
4891 39085
55044 20658
64402 46615
55644 18440
39390 4555
30326 22354...

output:

2 35692

result:

ok single line: '2 35692'

Test #31:

score: 0
Accepted
time: 141ms
memory: 36284kb

input:

100000
98146 41437
64264 92243
40404 85224
8836 46210
11730 92295
48430 64785
58329 40515
5594 71557
34172 8410
22738 43234
75383 80493
28529 7518
13991 52686
48202 14413
43591 55352
96066 53620
98829 1884
41833 16873
53878 91772
71745 82170
97812 35856
85722 33806
69101 37593
2039 5132
21275 44961
...

output:

2 9057

result:

ok single line: '2 9057'

Test #32:

score: 0
Accepted
time: 146ms
memory: 36944kb

input:

100000
84797 56972
91173 79708
34566 91465
53920 69507
54562 98588
78475 94082
11282 32093
31486 79308
95815 73692
72906 25081
22139 71165
15858 34332
53049 46673
21839 1668
779 61388
72136 91016
34893 75603
67847 55788
48222 32158
30170 50241
75323 57131
43728 35406
18136 42200
59856 77667
54199 59...

output:

2 12473

result:

ok single line: '2 12473'

Test #33:

score: 0
Accepted
time: 119ms
memory: 36132kb

input:

100000
98860 31370
4948 55446
17531 93993
6860 66382
20503 12382
282 85306
94584 25178
48454 47594
70192 84554
32609 7946
27525 67176
67902 40410
71966 76549
44992 3792
48716 45927
32342 95361
82627 95745
43342 64535
75099 81751
53750 68867
5883 9315
38812 26079
50275 84827
17674 9429
10870 51258
36...

output:

2 34604

result:

ok single line: '2 34604'

Test #34:

score: 0
Accepted
time: 67ms
memory: 33256kb

input:

58569
3229 50374
29303 7184
49702 2997
51981 48079
21839 5885
40683 40228
15426 11350
54794 29129
133 47547
23882 6593
47346 56221
52412 51608
2641 6464
31601 40067
44746 46483
45862 12350
27494 48192
6185 12802
56526 54300
45037 33580
13632 56810
2617 29980
17642 33674
31982 28248
52415 21722
57028...

output:

2 4165

result:

ok single line: '2 4165'

Test #35:

score: 0
Accepted
time: 0ms
memory: 29476kb

input:

5832
2219 790
3424 2858
3803 3265
1044 712
2188 4790
2572 843
4117 4409
1007 1133
1061 1808
3805 3625
2851 3683
518 4659
2998 5749
2195 4894
5246 2002
2493 5130
1558 498
1033 1820
2310 689
2690 1965
1528 553
4148 4958
23 334
299 5492
5381 3505
1938 3201
3704 5504
2764 1332
1374 3222
1902 1934
261 28...

output:

2 558

result:

ok single line: '2 558'

Test #36:

score: 0
Accepted
time: 0ms
memory: 28796kb

input:

3662
1399 887
797 2372
197 4
804 2172
3496 1829
638 849
1347 2261
174 3532
85 3248
2059 2652
524 1208
1357 1124
1538 2204
1604 506
3258 3643
1629 3209
1815 1593
363 1493
12 2421
3560 1536
2397 851
2914 3207
2957 802
1769 1783
3017 3638
455 3263
3204 1679
3433 377
1560 3493
3200 3619
2431 2564
77 459...

output:

2 376

result:

ok single line: '2 376'

Test #37:

score: 0
Accepted
time: 84ms
memory: 35812kb

input:

77933
44335 76838
12279 2151
44335 67326
7431 44335
4133 17927
44335 62217
23932 44335
45946 54874
44335 59185
48665 44335
53304 48183
50442 8923
44335 33312
9518 73927
46532 44335
9080 34089
16551 4988
47703 7319
13969 16024
9818 27360
11654 67769
22449 60267
58767 67897
38955 44335
73702 28491
259...

output:

3 65822

result:

ok single line: '3 65822'

Test #38:

score: 0
Accepted
time: 78ms
memory: 35356kb

input:

75763
11922 7503
61320 51096
33544 52601
13891 52601
61761 36023
67825 51864
19995 19925
40609 16005
39745 12361
33613 11415
71202 30614
67567 44101
71795 11415
18887 21049
60807 56970
67317 25281
40751 21753
20911 32963
36137 15710
25563 36552
5358 44140
11415 70403
11415 67060
69145 54409
40027 58...

output:

3 56594

result:

ok single line: '3 56594'

Test #39:

score: 0
Accepted
time: 101ms
memory: 38068kb

input:

100000
91107 81646
43706 61163
26194 78328
26802 7678
22113 18594
31166 3127
52838 4091
47037 13226
93316 19667
18682 28359
21780 11471
5106 27596
38559 38801
93408 56006
82493 56981
223 97620
4456 92381
84643 75597
44723 88393
91969 28821
7839 43479
40054 23662
93649 92778
23342 65655
43041 9088
53...

output:

3 78142

result:

ok single line: '3 78142'

Test #40:

score: 0
Accepted
time: 140ms
memory: 37464kb

input:

100000
15326 24168
70504 65867
37711 56785
68094 41262
31806 8453
98505 67620
35071 9823
78082 22414
48804 47448
47971 60367
26750 48302
87999 67146
2620 52410
48280 60198
64145 15403
38525 10322
52425 28896
96240 27566
22000 59001
40589 88039
69313 4557
87575 4662
90975 10417
88142 14197
59642 6368...

output:

3 25329

result:

ok single line: '3 25329'

Test #41:

score: 0
Accepted
time: 142ms
memory: 38044kb

input:

100000
67346 18542
17781 62256
20669 30707
6315 47433
90299 38739
85776 53468
94988 23489
57285 86153
15629 67105
65345 38091
68444 92968
29699 92434
76334 60732
30482 88014
55722 41531
23387 618
11713 29069
29459 10721
86150 39681
38313 89207
57855 60143
80383 67917
25344 15109
54304 1254
52962 576...

output:

3 30027

result:

ok single line: '3 30027'

Test #42:

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

input:

3662
478 508
334 280
283 2785
3008 660
2073 960
617 719
2956 2912
3030 1504
332 652
1437 214
1702 564
583 1065
2367 2275
575 319
330 856
359 298
654 3543
3398 3461
2032 904
1211 38
1219 1757
1348 408
1769 2629
602 990
39 1024
949 2907
3577 628
1949 2158
2080 1304
3333 2598
250 2184
3506 551
2699 144...

output:

3 1142

result:

ok single line: '3 1142'

Test #43:

score: 0
Accepted
time: 123ms
memory: 37156kb

input:

100000
27200 83781
60101 6346
90291 38664
24254 99847
849 15388
33067 46251
47211 62962
22845 53425
7527 10068
33947 60317
67507 77363
38607 8319
85978 73777
29040 40228
79464 55185
43428 49125
27130 72305
18822 43370
23032 13939
83557 13423
18763 41648
77161 52350
74849 96571
79929 61474
66967 1658...

output:

3 48869

result:

ok single line: '3 48869'

Test #44:

score: 0
Accepted
time: 120ms
memory: 37524kb

input:

100000
18740 2744
94574 71445
31982 15060
11287 75593
35765 62539
8110 86809
22263 11866
2930 36727
87569 83349
31060 11297
51994 11009
21960 1432
76996 80609
49488 5464
66795 4012
44380 50255
32304 22017
43438 82290
30630 31687
98377 33594
58477 17182
25179 47413
96008 92835
20447 28696
12860 49037...

output:

3 73015

result:

ok single line: '3 73015'

Test #45:

score: 0
Accepted
time: 115ms
memory: 38080kb

input:

100000
23845 46702
27145 71228
42765 3532
937 39417
39417 26055
4035 39417
72597 85637
41041 63293
39417 87063
40109 21582
70205 38876
39417 71563
94885 20124
25225 39417
26367 60924
307 39417
72211 7627
39417 65882
55729 84350
74940 871
48339 86139
30298 95273
79245 88552
41651 93256
12448 64502
18...

output:

3 79199

result:

ok single line: '3 79199'

Test #46:

score: 0
Accepted
time: 140ms
memory: 37244kb

input:

100000
58425 2635
58118 11868
36250 39202
11421 45731
51115 47869
90127 67448
44956 74805
62642 7907
56822 83398
43831 5438
7873 28767
75150 39257
31366 36889
44360 66158
74352 45224
51492 45952
37537 41436
50922 40861
92070 78212
16136 36650
22146 59403
52471 82674
93294 16026
41221 35043
4066 5532...

output:

3 28546

result:

ok single line: '3 28546'

Test #47:

score: 0
Accepted
time: 136ms
memory: 38044kb

input:

100000
35844 73927
97762 21770
87930 39068
64966 1551
33285 52941
13862 1207
52545 35210
19514 32411
88949 6634
42090 62253
89243 60638
45625 18656
9568 49126
70028 85082
15494 19505
74165 68957
1675 54752
72469 30121
38027 2129
11330 6772
8089 74586
79838 97395
68414 74126
22993 91857
15425 23689
9...

output:

3 30871

result:

ok single line: '3 30871'

Test #48:

score: 0
Accepted
time: 126ms
memory: 37764kb

input:

100000
83643 58367
43702 10414
86815 61051
94700 59236
52264 17154
71049 80152
92168 1822
37638 11117
52104 18958
95387 54706
86597 82771
60058 82477
41480 2697
92539 23737
9854 72571
4371 73222
44205 74036
48403 85711
20305 29002
40686 84707
74720 68143
6733 32725
36665 12239
23232 83532
51398 8352...

output:

3 30292

result:

ok single line: '3 30292'

Test #49:

score: 0
Accepted
time: 126ms
memory: 37232kb

input:

100000
3658 7962
94329 93818
5830 64431
35161 6958
44065 59424
70443 63577
91047 54244
88712 738
22641 22251
83793 63655
83517 64301
37924 304
85759 36500
14338 85518
13356 48111
3058 29418
31665 77415
51307 94888
68953 65178
82532 14827
71196 68470
13889 1486
83415 5862
51160 55530
35930 1026
43323...

output:

3 49909

result:

ok single line: '3 49909'

Test #50:

score: 0
Accepted
time: 148ms
memory: 38108kb

input:

100000
23871 46834
66257 57929
18416 48933
16221 56764
67224 88179
24127 51973
52018 56721
72351 90930
29047 66269
96427 49405
36047 46659
97214 46079
95071 67853
36234 65204
67466 50126
81102 2030
90420 44622
1899 36691
2404 53477
43819 3291
68460 54099
56881 77278
48260 48449
7959 90112
35121 4951...

output:

3 29665

result:

ok single line: '3 29665'

Test #51:

score: 0
Accepted
time: 84ms
memory: 34932kb

input:

66792
2131 47855
39027 12980
66302 22689
8260 8708
11430 7792
21959 42413
4892 58843
56071 46820
21457 61033
21115 66054
20014 4483
2714 16233
21609 39678
17993 55312
17170 14226
5303 47328
58814 22937
34478 61003
3420 34968
24755 378
31616 54915
2079 9911
37380 66562
54830 37912
33358 11072
6375 22...

output:

3 19398

result:

ok single line: '3 19398'

Test #52:

score: 0
Accepted
time: 153ms
memory: 38272kb

input:

100000
26449 18382
72673 46769
69831 66558
38777 37080
12578 21435
55747 8835
28622 44592
98824 70257
29415 67955
91643 85234
40116 49481
77613 37079
33146 97471
57163 14978
97747 42024
19590 75059
78011 67420
36209 72511
24611 81795
83375 54294
88807 42856
8755 12802
4019 49396
89048 76235
91684 62...

output:

3 29155

result:

ok single line: '3 29155'

Test #53:

score: 0
Accepted
time: 141ms
memory: 38476kb

input:

100000
86172 4444
24258 20155
71734 55930
3451 97104
44023 71698
99068 30289
42835 12548
60891 37221
37278 28561
54627 27120
27727 34345
67204 31066
24643 30459
57376 24551
13428 2397
61470 55887
26818 92080
81624 92060
50695 56159
12197 65098
22715 30883
56174 81832
38578 1414
26106 27479
884 83249...

output:

3 29538

result:

ok single line: '3 29538'

Test #54:

score: 0
Accepted
time: 104ms
memory: 36160kb

input:

85321
82304 80633
34981 57456
25157 35656
63628 631
45370 57752
39778 23052
40879 78572
79533 54682
56112 52000
25134 14537
30074 45178
77944 81852
4556 71485
58021 63654
45191 30182
66123 52189
78092 1925
32516 13590
48781 65043
21312 33389
59709 20695
38278 8080
36314 53547
6464 66111
5098 55875
2...

output:

3 23489

result:

ok single line: '3 23489'

Test #55:

score: 0
Accepted
time: 143ms
memory: 38044kb

input:

100000
96500 98710
4924 44406
4144 79840
20048 89661
85448 77477
2189 7822
40466 21784
90737 32531
16092 20
11106 34004
9029 39672
66180 32874
77737 9401
92545 27916
18261 8745
33947 63943
66625 23209
51320 48333
80944 12306
13037 43377
28081 59680
21850 88453
65246 96252
11852 21879
94985 84579
135...

output:

3 27874

result:

ok single line: '3 27874'

Test #56:

score: 0
Accepted
time: 73ms
memory: 34092kb

input:

60041
23239 4572
54184 29295
5551 33707
4406 25499
52447 3391
23141 57552
52138 54882
23940 25222
9697 57721
32763 38440
36281 23362
13342 53282
9 26670
4170 24916
11350 48844
2686 43173
43804 54059
34288 20296
12319 21921
41641 24436
31912 47859
1110 53816
9170 1110
33094 38188
41348 19122
31162 47...

output:

3 17818

result:

ok single line: '3 17818'

Test #57:

score: 0
Accepted
time: 147ms
memory: 38856kb

input:

100000
64801 93871
93891 61733
61528 17600
93650 45858
80555 27465
43428 51040
81995 84901
92992 53237
9351 26477
4374 55494
88751 35610
2981 73483
69036 61267
29418 42664
65609 49456
31486 31476
77427 69130
81957 16348
35730 75249
29998 55642
75451 57081
65478 6986
94985 97197
53207 82664
86977 702...

output:

3 15398

result:

ok single line: '3 15398'

Test #58:

score: 0
Accepted
time: 139ms
memory: 37440kb

input:

100000
21751 80344
14758 8293
85281 32212
15230 97277
42271 86850
50479 52827
37882 85097
4160 52500
21935 59827
96848 42018
26394 19604
44315 33337
41611 25195
15699 70733
42808 57166
25734 32402
91813 27113
8084 23854
75645 65772
2354 18512
68042 28643
47213 10618
48029 50512
51714 59200
15703 485...

output:

3 28695

result:

ok single line: '3 28695'

Test #59:

score: 0
Accepted
time: 135ms
memory: 38080kb

input:

100000
25780 28674
23847 31181
60260 88483
97905 2326
97021 98441
44854 32639
26693 82673
29743 97372
64789 64394
69360 14977
60347 38476
27072 29778
69223 30371
91153 38569
17382 92332
83455 51027
91164 38628
54054 49386
4285 25460
12338 2843
53259 49627
1289 99732
59000 29463
52833 45199
12449 956...

output:

3 30788

result:

ok single line: '3 30788'