QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#121783#2596. Even ForestBZJRNAC ✓245ms110800kbC++14634b2023-07-08 20:41:592023-07-08 20:42:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-08 20:42:01]
  • 评测
  • 测评结果:AC
  • 用时:245ms
  • 内存:110800kb
  • [2023-07-08 20:41:59]
  • 提交

answer

#include<stdio.h>
int n,u,v,i=1,e[2000003],d[1000002],f[1000002],hd[1000002],nxt[2000003],dp[1000002][2];
void df(int x,int fa){
	int y,p=hd[x],t=nxt[p];
	for(f[x]=1-f[fa],dp[x][!f[x]]=!t;p;p=nxt[p]){
		if(e[p]-fa){
			y=e[p],df(y,x);
			dp[x][0]+=d[y]+1<dp[y][0]?d[y]+1:dp[y][0];
			dp[x][1]+=d[y]+1<dp[y][1]?d[y]+1:dp[y][1];
		}
	}
	d[x]=nxt[t]&&dp[x][1-f[x]]<dp[x][f[x]]?dp[x][1-f[x]]:dp[x][f[x]];
}
int main(){
	for(scanf("%d",&n);i<n*2-1;++i)scanf("%d%d",&u,&v),e[i]=v,nxt[i]=hd[u],hd[u]=i,++i,e[i]=u,nxt[i]=hd[v],hd[v]=i;
	df(1,0),printf("\n%d",nxt[hd[1]]&&dp[1][1-f[1]]<dp[1][f[1]]?dp[1][1-f[1]]:dp[1][f[1]]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
2 3
3 4

output:


1

result:

ok 1 number(s): "1"

Test #2:

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

input:

4
1 2
1 3
1 4

output:


0

result:

ok 1 number(s): "0"

Test #3:

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

input:

6
1 2
2 3
4 2
4 5
6 4

output:


1

result:

ok 1 number(s): "1"

Test #4:

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

input:

1

output:


0

result:

ok 1 number(s): "0"

Test #5:

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

input:

2
1 2

output:


1

result:

ok 1 number(s): "1"

Test #6:

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

input:

3
2 3
3 1

output:


0

result:

ok 1 number(s): "0"

Test #7:

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

input:

4
2 3
3 1
3 4

output:


0

result:

ok 1 number(s): "0"

Test #8:

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

input:

5
4 2
2 3
4 1
5 3

output:


0

result:

ok 1 number(s): "0"

Test #9:

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

input:

6
4 3
1 4
2 4
5 2
4 6

output:


1

result:

ok 1 number(s): "1"

Test #10:

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

input:

50
21 22
22 27
22 7
22 12
22 13
43 22
36 22
35 22
6 22
10 22
22 38
19 22
34 22
8 22
22 44
22 3
9 22
22 16
23 22
18 22
22 25
22 5
22 2
22 15
46 22
37 22
48 22
33 22
22 17
31 22
22 29
22 28
22 49
4 22
22 26
41 22
22 32
22 50
22 20
22 30
24 22
40 22
22 45
14 22
22 11
42 22
39 22
1 22
47 22

output:


0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 162ms
memory: 36640kb

input:

1000000
851841 325834
455962 325834
135775 325834
525341 325834
265267 325834
868520 325834
834325 325834
867971 325834
325834 879726
325834 242607
325834 106951
122113 325834
325834 499633
727580 325834
325834 200171
325834 178877
325834 493841
957118 325834
325834 809324
325834 641895
325834 33338...

output:


0

result:

ok 1 number(s): "0"

Test #12:

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

input:

3
2 1
2 3

output:


0

result:

ok 1 number(s): "0"

Test #13:

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

input:

4
4 3
1 4
1 2

output:


1

result:

ok 1 number(s): "1"

Test #14:

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

input:

5
1 4
2 4
3 2
3 5

output:


0

result:

ok 1 number(s): "0"

Test #15:

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

input:

6
3 5
3 6
1 6
1 4
4 2

output:


1

result:

ok 1 number(s): "1"

Test #16:

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

input:

7
1 2
3 2
6 3
6 7
7 4
4 5

output:


0

result:

ok 1 number(s): "0"

Test #17:

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

input:

8
6 2
1 2
8 1
5 8
5 7
7 3
4 3

output:


1

result:

ok 1 number(s): "1"

Test #18:

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

input:

20
6 1
6 15
9 15
18 9
18 17
17 7
8 7
3 8
19 3
2 19
13 2
13 11
12 11
12 14
4 14
4 5
20 5
16 20
16 10

output:


1

result:

ok 1 number(s): "1"

Test #19:

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

input:

42
33 30
17 33
17 7
29 7
15 29
15 23
23 1
10 1
10 31
4 31
12 4
12 34
28 34
28 41
41 11
32 11
32 24
13 24
13 19
26 19
16 26
35 16
35 27
37 27
37 3
3 20
8 20
39 8
6 39
6 42
14 42
14 38
38 9
25 9
18 25
18 5
36 5
36 40
40 21
21 2
22 2

output:


1

result:

ok 1 number(s): "1"

Test #20:

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

input:

27
19 14
6 19
16 19
19 7
19 4
21 19
26 4
26 15
4 5
5 1
10 26
13 26
17 7
3 4
23 13
21 25
2 25
2 12
10 9
20 17
24 16
21 27
22 13
8 16
18 7
11 24

output:


6

result:

ok 1 number(s): "6"

Test #21:

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

input:

2007
1852 380
380 1300
1437 380
380 1789
380 876
380 1427
1295 1852
380 1549
782 1549
205 380
1789 446
1300 1113
380 417
446 1357
1295 242
446 1758
579 417
562 242
1086 1437
1584 876
579 1981
1873 1789
1918 1789
376 1437
1113 1564
30 1113
1357 1197
221 446
1300 128
386 579
1918 1126
479 1549
1026 15...

output:


326

result:

ok 1 number(s): "326"

Test #22:

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

input:

582
422 513
284 422
571 422
148 422
422 315
420 422
422 143
92 422
422 94
177 422
67 422
112 422
422 424
343 422
219 422
422 263
422 131
19 422
422 322
422 257
455 422
371 422
422 580
431 422
422 160
123 422
531 422
422 474
422 189
471 422
422 168
77 422
438 422
232 422
422 336
239 422
422 467
186 4...

output:


65

result:

ok 1 number(s): "65"

Test #23:

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

input:

2007
1191 1713
1191 1921
1191 63
1191 272
1191 774
1191 1116
656 1191
1191 154
1872 1191
453 1191
1191 411
1599 1191
1420 1191
810 1191
1191 1470
1191 1017
457 1191
1191 987
101 1191
1794 1191
1191 1404
134 1191
1080 1191
918 1191
955 1191
1191 1124
1191 1042
1191 1369
1191 51
88 1191
1315 1191
1191...

output:


7

result:

ok 1 number(s): "7"

Test #24:

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

input:

50
43 40
28 43
32 43
50 43
29 43
43 45
43 49
43 2
43 5
43 23
7 43
43 31
43 35
43 38
4 43
16 43
43 8
20 43
20 33
43 13
39 13
9 43
17 9
18 43
18 37
43 42
42 25
43 14
41 14
43 10
27 10
3 43
48 3
43 26
19 26
43 47
24 47
21 43
6 21
11 43
11 34
43 30
22 30
43 44
46 44
43 1
1 12
43 36
36 15

output:


16

result:

ok 1 number(s): "16"

Test #25:

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

input:

505
4 447
447 441
120 447
238 447
447 108
447 256
38 447
447 464
77 447
292 447
447 276
130 447
237 447
478 447
100 447
414 447
245 447
447 195
295 447
349 447
447 119
173 447
203 447
501 447
192 447
447 421
447 223
447 282
470 447
447 174
128 447
447 422
236 447
104 447
91 447
447 16
447 270
447 42...

output:


168

result:

ok 1 number(s): "168"

Test #26:

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

input:

5500
4460 4560
4560 144
254 4560
4560 1154
1101 4560
4560 5187
729 4560
4560 298
4560 22
4441 4560
1706 4560
2584 4560
4560 3066
2773 4560
4560 2333
4560 3361
3821 4560
5438 4560
467 4560
908 4560
1682 4560
4560 1340
4560 3916
4560 2230
5190 4560
4560 3998
4560 1318
4560 1834
2237 4560
1263 4560
504...

output:


1833

result:

ok 1 number(s): "1833"

Test #27:

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

input:

50555
36789 49023
43923 36789
36789 13246
36789 48699
2773 36789
39874 36789
36789 16692
36789 17216
44101 36789
10095 36789
36789 10290
36789 50112
40378 36789
31137 36789
36789 8862
36789 16420
49359 36789
11341 36789
36789 19825
36789 23690
36789 38450
3972 36789
36789 43666
39461 36789
14201 367...

output:


16851

result:

ok 1 number(s): "16851"

Test #28:

score: 0
Accepted
time: 83ms
memory: 27096kb

input:

505000
381245 387591
381245 193068
246759 381245
381245 408770
113785 381245
377328 381245
394893 381245
381245 425648
448511 381245
381245 305387
381245 193354
499135 381245
381245 181417
305596 381245
381245 204529
381245 380041
488911 381245
76718 381245
381245 248514
381245 452149
381245 425516
...

output:


168333

result:

ok 1 number(s): "168333"

Test #29:

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

input:

1000000
986875 629957
986875 931053
986875 77814
986875 116863
986875 154708
986875 121402
986875 273150
986875 368825
538061 986875
894517 986875
665786 986875
986875 240057
981735 986875
986875 154176
583988 986875
787550 986875
585571 986875
986875 655060
989566 986875
121052 986875
671384 986875...

output:


333333

result:

ok 1 number(s): "333333"

Test #30:

score: 0
Accepted
time: 174ms
memory: 36624kb

input:

1000000
227871 955120
227871 690016
227871 180027
227871 751799
268526 227871
526636 227871
970122 227871
452015 227871
227871 766778
227871 685720
227871 650207
227871 977238
581273 227871
199253 227871
227871 208659
227871 726438
70773 227871
440886 227871
227871 385013
230118 227871
792363 227871...

output:


219295

result:

ok 1 number(s): "219295"

Test #31:

score: 0
Accepted
time: 154ms
memory: 36728kb

input:

1000000
742740 400594
400594 980404
913320 400594
400594 611227
930291 400594
872935 400594
84718 400594
351806 400594
746664 400594
500676 400594
294634 400594
809371 400594
803109 400594
572897 400594
400594 668232
598480 400594
476146 400594
537662 400594
197536 400594
400594 944275
640135 400594...

output:


85598

result:

ok 1 number(s): "85598"

Test #32:

score: 0
Accepted
time: 184ms
memory: 36744kb

input:

1000000
211617 660262
852360 660262
660262 45281
660262 820334
95971 660262
712556 660262
660262 243112
423933 660262
660262 246067
705132 660262
660262 589878
466992 660262
346803 660262
176058 660262
660262 120286
660262 924322
660262 284641
125075 660262
918758 660262
963266 660262
313827 660262
...

output:


173410

result:

ok 1 number(s): "173410"

Test #33:

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

input:

7070
2700 5242
5427 5242
5427 5802
936 5802
936 616
616 3371
3371 4885
4885 3584
603 3584
603 5766
3020 5766
6309 3020
4941 6309
235 4941
6159 235
1025 6159
2818 1025
2818 778
5879 778
5879 3796
201 3796
4995 201
4995 1305
1480 1305
1480 613
3945 613
3945 604
604 2750
2750 1653
1653 2640
1360 2640
1...

output:


1

result:

ok 1 number(s): "1"

Test #34:

score: 0
Accepted
time: 26ms
memory: 28692kb

input:

212505
161819 203402
106552 161819
106552 9818
112331 9818
112331 129372
153745 129372
90451 153745
90450 90451
90450 34622
63420 34622
152044 63420
152044 72113
111434 72113
111434 42791
42791 35241
129822 35241
74242 129822
175055 74242
147763 175055
147763 97572
42978 97572
42978 22870
22870 2067...

output:


0

result:

ok 1 number(s): "0"

Test #35:

score: 0
Accepted
time: 207ms
memory: 110800kb

input:

1000000
986875 629957
629957 931053
931053 77814
77814 116863
116863 154708
154708 121402
121402 273150
273150 368825
538061 368825
894517 538061
665786 894517
665786 240057
981735 240057
981735 154176
583988 154176
787550 583988
585571 787550
585571 655060
989566 655060
121052 989566
671384 121052
...

output:


1

result:

ok 1 number(s): "1"

Test #36:

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

input:

7
2 5
7 6
7 4
3 1
7 1
5 7

output:


2

result:

ok 1 number(s): "2"

Test #37:

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

input:

8
7 1
4 8
5 1
8 1
2 3
4 6
7 3

output:


0

result:

ok 1 number(s): "0"

Test #38:

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

input:

9
6 2
2 3
5 1
1 2
5 7
9 3
2 8
4 8

output:


2

result:

ok 1 number(s): "2"

Test #39:

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

input:

10
1 5
9 2
10 8
9 8
3 10
6 10
10 7
4 8
9 1

output:


2

result:

ok 1 number(s): "2"

Test #40:

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

input:

20
14 10
4 12
12 13
6 7
17 15
11 18
6 16
10 5
8 2
5 9
7 13
9 6
20 8
16 8
9 15
8 1
18 3
15 19
13 18

output:


2

result:

ok 1 number(s): "2"

Test #41:

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

input:

42
7 1
1 35
39 1
1 17
27 1
6 4
5 1
15 1
1 22
1 33
1 34
1 11
31 1
32 1
1 28
1 36
1 30
3 1
29 1
1 26
30 14
24 1
2 38
1 18
1 2
1 40
1 41
8 1
12 1
1 13
19 1
16 1
6 1
23 1
42 1
10 1
21 1
9 1
6 37
20 1
25 1

output:


3

result:

ok 1 number(s): "3"

Test #42:

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

input:

42
1 18
11 26
1 42
40 1
20 4
15 21
27 20
41 5
24 28
24 34
10 1
1 22
6 24
24 31
37 24
9 20
20 36
41 1
1 39
20 21
23 7
33 20
18 12
1 23
24 13
1 38
11 3
1 19
32 20
1 11
1 8
17 23
29 23
24 25
18 30
14 20
20 1
23 35
1 24
16 41
23 2

output:


7

result:

ok 1 number(s): "7"

Test #43:

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

input:

42
1 22
25 36
30 16
35 19
38 39
12 1
1 42
1 39
16 37
1 40
28 35
1 4
31 6
21 39
8 1
37 23
37 27
3 42
37 20
10 14
26 17
37 24
37 1
1 10
37 33
35 18
17 39
9 21
29 28
5 1
39 35
7 1
4 41
1 6
1 13
22 15
1 36
32 1
11 22
1 34
36 2

output:


10

result:

ok 1 number(s): "10"

Test #44:

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

input:

42
31 35
2 28
40 6
33 22
2 8
36 8
38 2
33 21
14 8
3 28
24 31
15 1
41 10
27 32
12 2
13 1
26 32
34 1
2 23
8 11
31 7
39 8
2 1
6 1
31 20
17 24
31 1
25 33
2 33
37 33
10 33
19 25
30 1
5 2
18 8
9 34
36 42
1 4
16 33
32 6
24 29

output:


11

result:

ok 1 number(s): "11"

Test #45:

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

input:

42
28 8
1 3
14 39
1 24
6 39
15 8
10 23
41 39
37 1
34 1
16 1
17 1
33 27
19 8
39 18
33 30
1 33
35 25
31 13
29 31
25 1
1 8
40 9
1 5
31 1
41 1
25 7
22 33
11 8
8 38
33 20
4 33
28 12
36 31
32 23
33 2
23 1
9 1
1 26
36 21
31 42

output:


8

result:

ok 1 number(s): "8"

Test #46:

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

input:

42
20 24
17 31
39 1
30 33
27 34
40 18
36 19
12 37
24 16
15 11
27 29
40 13
39 7
19 23
9 26
15 29
29 19
39 42
39 28
24 1
41 39
2 14
12 21
24 35
29 39
3 39
29 38
29 12
23 25
10 4
4 15
1 40
32 29
32 31
6 35
19 14
29 30
39 8
22 35
5 1
9 41

output:


7

result:

ok 1 number(s): "7"

Test #47:

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

input:

42
10 14
6 29
30 27
2 10
36 23
21 5
11 13
6 17
32 16
10 1
12 28
15 26
5 42
19 37
3 31
20 25
28 19
1 36
35 10
39 18
33 26
13 6
27 21
40 10
21 36
10 29
18 10
12 8
34 10
4 2
21 41
20 7
5 16
22 3
36 15
22 38
39 20
12 24
9 29
10 12
22 20

output:


8

result:

ok 1 number(s): "8"

Test #48:

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

input:

42
38 21
11 2
13 23
12 41
11 23
3 10
27 26
34 10
25 5
4 40
13 22
9 34
39 19
20 30
28 17
40 8
29 13
33 4
31 40
31 10
18 31
12 32
19 7
25 3
25 26
17 24
20 34
3 11
1 16
37 21
14 39
25 38
14 1
28 15
35 12
36 16
6 14
36 24
24 12
11 42
3 36

output:


6

result:

ok 1 number(s): "6"

Test #49:

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

input:

42
23 17
32 6
7 37
22 30
36 15
17 37
5 30
15 20
19 29
14 30
13 29
26 5
2 38
39 22
7 9
27 24
28 26
3 11
30 31
20 21
16 41
32 42
1 42
33 30
4 8
8 35
6 24
21 27
11 30
20 12
40 41
12 22
22 29
35 31
14 7
2 18
25 4
7 2
10 20
41 39
19 34

output:


5

result:

ok 1 number(s): "5"

Test #50:

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

input:

42
41 34
20 14
7 24
40 22
7 21
27 4
26 8
36 28
17 29
22 11
3 20
32 30
37 36
30 7
27 11
31 37
33 38
20 39
25 28
21 2
32 18
19 4
21 15
13 38
39 5
37 10
12 15
25 32
4 29
9 35
37 23
36 41
8 25
33 35
6 16
33 25
32 5
19 16
22 21
1 40
8 42

output:


5

result:

ok 1 number(s): "5"

Test #51:

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

input:

42
32 18
37 19
19 14
26 32
18 39
14 5
20 1
2 37
38 40
7 17
10 4
11 36
16 30
20 17
27 9
28 15
27 5
16 9
21 14
3 9
32 38
31 18
42 37
11 37
15 22
19 35
9 6
7 41
42 12
9 24
23 13
41 30
42 23
3 22
34 13
8 32
37 33
29 25
2 10
26 29
38 16

output:


6

result:

ok 1 number(s): "6"

Test #52:

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

input:

42
41 13
32 28
16 24
21 5
27 24
21 28
25 22
10 41
30 33
6 18
24 9
18 26
23 21
22 8
8 19
33 2
39 17
2 21
26 20
35 40
15 31
37 38
30 24
29 20
4 16
3 19
12 32
26 7
3 4
26 15
14 19
42 35
13 38
10 6
19 40
1 37
40 34
31 16
6 39
39 11
36 21

output:


3

result:

ok 1 number(s): "3"

Test #53:

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

input:

42
27 42
7 39
10 34
36 21
23 16
11 30
33 7
20 9
42 28
21 1
29 6
11 8
31 15
14 16
36 5
7 27
12 2
39 40
16 20
32 42
37 38
9 30
33 41
28 34
35 29
18 23
24 4
26 15
35 26
32 17
24 16
19 15
38 5
25 15
22 37
38 18
13 12
13 3
15 30
15 39
2 20

output:


4

result:

ok 1 number(s): "4"

Test #54:

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

input:

42
25 37
5 7
18 34
21 23
6 26
27 19
30 37
29 17
26 33
7 31
14 37
42 30
41 16
12 5
39 15
10 30
35 32
38 20
5 2
41 30
27 9
26 22
15 26
4 13
29 1
19 26
32 6
11 36
26 8
18 32
32 42
21 14
16 3
36 38
20 23
13 29
7 30
23 28
22 24
17 28
40 14

output:


7

result:

ok 1 number(s): "7"

Test #55:

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

input:

42
6 36
27 25
26 42
18 8
41 35
12 34
29 11
3 21
9 36
24 10
23 21
22 9
10 7
5 25
22 24
30 33
37 18
18 27
25 41
21 28
42 3
17 39
22 14
5 13
29 4
1 11
38 2
20 35
33 21
4 10
2 34
19 23
31 26
39 31
9 16
34 32
12 28
39 40
33 15
20 12
16 17

output:


3

result:

ok 1 number(s): "3"

Test #56:

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

input:

42
4 34
2 22
35 40
17 25
25 41
3 11
39 14
17 31
26 34
39 30
13 24
28 8
5 24
18 29
6 41
36 19
10 30
3 12
38 27
15 30
38 22
21 20
7 19
23 11
29 32
18 7
15 21
6 10
8 26
42 33
14 37
36 33
2 20
12 32
40 34
9 17
42 13
5 1
9 23
4 16
27 28

output:


1

result:

ok 1 number(s): "1"

Test #57:

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

input:

77
59 2
72 77
11 24
37 41
60 77
57 4
55 2
9 19
9 14
18 72
68 65
12 37
19 23
26 19
8 3
1 60
61 51
64 62
54 37
40 25
29 16
23 34
28 62
67 51
58 39
69 36
35 71
40 68
13 63
42 76
17 75
49 58
51 57
3 72
48 6
62 45
50 5
76 43
2 18
39 22
66 1
57 16
75 6
7 48
73 70
54 3
46 10
3 32
13 62
60 11
20 52
39 30
57...

output:


12

result:

ok 1 number(s): "12"

Test #58:

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

input:

118
61 38
109 33
105 100
35 4
56 16
65 76
94 97
15 44
26 9
55 95
95 37
108 72
99 86
47 112
15 71
103 84
53 61
62 61
8 34
70 58
62 2
86 23
43 48
41 43
114 15
115 16
113 92
67 6
29 30
63 89
56 7
111 31
4 20
93 87
17 74
100 114
62 41
73 12
14 101
82 31
102 106
36 26
27 40
57 20
25 23
85 115
15 89
83 84...

output:


17

result:

ok 1 number(s): "17"

Test #59:

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

input:

2929
1108 2254
1421 1049
1643 2631
772 1010
957 2244
950 1651
2758 766
1779 290
58 1510
333 826
2295 1947
1281 2325
1549 2154
1598 312
461 130
1664 143
308 2211
1568 308
475 27
560 109
2902 888
2814 2055
396 2226
976 1272
1015 1684
2266 2584
395 365
1283 1372
1063 2602
1324 2139
2491 914
549 316
109...

output:


434

result:

ok 1 number(s): "434"

Test #60:

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

input:

9005
7023 1667
4341 2423
8378 371
7542 6958
8961 2604
3393 8329
8412 7704
5069 8978
2646 6895
7026 1079
6321 6750
5132 811
2474 8168
1882 1357
1005 5196
1724 718
1928 1236
1419 1369
1662 552
8331 7947
5758 4194
5287 1379
8225 1656
1510 7846
3700 2357
5203 2486
3222 7760
5993 3766
1225 7756
7778 6131...

output:


1272

result:

ok 1 number(s): "1272"

Test #61:

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

input:

50505
49965 26419
3530 17582
31540 19884
7466 35734
12653 27005
24912 37632
2808 35052
44884 41543
10348 14858
46359 47209
3246 21575
20007 29575
314 18229
933 297
1437 13901
3928 25876
37818 50099
49695 30165
28278 2384
40126 20461
38035 40469
17922 1504
3621 29861
47080 17435
12928 1436
25039 2609...

output:


7252

result:

ok 1 number(s): "7252"

Test #62:

score: 0
Accepted
time: 161ms
memory: 33668kb

input:

777666
282971 100348
313341 739459
270741 494355
109859 417273
34333 383597
383432 773661
746922 397358
724369 226700
546969 237891
11232 528889
636284 590791
501395 20559
191611 560143
276090 732591
583193 20274
36160 86217
733176 419680
170150 299397
474684 759388
347693 95676
458584 362636
267514...

output:


111448

result:

ok 1 number(s): "111448"

Test #63:

score: 0
Accepted
time: 201ms
memory: 36736kb

input:

999999
984373 757994
797790 315350
384806 872336
717314 141143
188548 543918
910356 125671
674164 963695
666712 520948
639107 533416
400063 830952
430662 10600
920226 489243
484485 709012
438979 130672
167271 369253
998921 903742
812959 941515
404902 851653
953669 716111
147448 999210
563246 430183
...

output:


143343

result:

ok 1 number(s): "143343"

Test #64:

score: 0
Accepted
time: 198ms
memory: 36708kb

input:

999998
362061 401400
52214 11427
271641 549012
26209 762262
588358 882719
222510 232920
173631 466459
390372 595662
94208 699465
460570 191614
143354 633023
263681 599659
68689 272597
736279 550110
246407 474254
351879 389822
91272 255018
541272 492584
637415 303623
103842 401292
222837 341579
72847...

output:


143056

result:

ok 1 number(s): "143056"

Test #65:

score: 0
Accepted
time: 171ms
memory: 36680kb

input:

1000000
633752 390812
163209 841830
164050 694282
914007 520573
769751 732845
613624 621661
89827 950111
566661 584341
637280 365864
184935 800389
867359 964542
871754 231134
462567 762145
54612 322734
55326 490431
28819 157098
430638 104207
533 732287
102008 138563
144098 702067
708588 107557
59092...

output:


57554

result:

ok 1 number(s): "57554"

Test #66:

score: 0
Accepted
time: 201ms
memory: 36628kb

input:

1000000
201157 216246
33699 83086
703431 741659
85123 887462
545615 815766
431721 33808
886282 748933
357297 923712
670796 591200
721998 101361
731474 768529
81055 661117
338108 476767
224056 272013
265765 437841
389475 126796
618359 816429
792248 218433
144576 86412
617026 99345
290460 720110
71596...

output:


195457

result:

ok 1 number(s): "195457"

Test #67:

score: 0
Accepted
time: 196ms
memory: 36720kb

input:

1000000
69211 908678
376498 771080
35661 604810
76101 427148
37133 533944
734676 310180
416049 930280
699002 53958
489620 106637
860220 483872
714516 311721
234960 412428
783086 272493
432893 642072
323692 500559
369641 102480
704803 578791
373333 108643
511865 505686
861533 451775
331518 259118
452...

output:


203330

result:

ok 1 number(s): "203330"

Test #68:

score: 0
Accepted
time: 200ms
memory: 36628kb

input:

1000000
931382 296911
40320 733701
282631 201141
21144 754471
19086 379531
738152 972204
991790 620994
77561 908920
778973 34010
943687 555505
269916 468245
88515 667856
353406 752249
909723 770735
428278 516695
576731 449516
217378 173557
72826 660688
705478 882465
498253 359451
967482 615008
26969...

output:


209297

result:

ok 1 number(s): "209297"

Test #69:

score: 0
Accepted
time: 203ms
memory: 36696kb

input:

1000000
157936 471075
999001 726771
826558 434915
456549 251226
128336 318843
507804 602557
67740 913699
945737 234770
242826 329090
634521 282015
84545 353804
686635 97154
209225 779185
442996 460871
280262 448533
348371 862127
682794 611908
442854 964813
404219 885526
587370 203983
402948 1
269382...

output:


208480

result:

ok 1 number(s): "208480"

Test #70:

score: 0
Accepted
time: 213ms
memory: 36728kb

input:

1000000
522202 420306
233712 769094
134687 783690
238782 949542
307669 125771
494560 378355
535706 71535
322039 910092
820748 131238
961012 625279
422141 516120
756159 973428
760982 685218
572351 521987
820587 244857
23989 443993
396099 607607
373392 240602
679217 407214
210426 105444
513395 22397
7...

output:


197645

result:

ok 1 number(s): "197645"

Test #71:

score: 0
Accepted
time: 225ms
memory: 36700kb

input:

1000000
964369 854761
896666 802733
386758 646153
359134 51775
781517 475888
393427 41469
892139 531818
366861 199593
642512 551984
349858 521020
886485 830951
131086 132900
478272 751394
413458 195897
69383 237328
150349 738096
69794 499383
239175 353158
738334 977338
422300 509947
586760 676379
47...

output:


168303

result:

ok 1 number(s): "168303"

Test #72:

score: 0
Accepted
time: 196ms
memory: 36728kb

input:

1000000
250143 146910
162590 763824
869332 894723
835007 684747
108029 611778
746728 727357
819183 597389
196350 437187
146990 897384
753018 778443
897703 905280
225220 5821
549878 840039
707352 558460
488999 757796
665098 433061
472223 710509
875517 204003
292404 615178
95555 26475
769155 676991
46...

output:


143173

result:

ok 1 number(s): "143173"

Test #73:

score: 0
Accepted
time: 202ms
memory: 36628kb

input:

1000000
167225 12877
733367 973802
970659 151319
642880 52758
655986 788368
220020 990028
636655 680658
990668 458028
287633 997731
875471 175346
964580 993752
140890 287368
976273 809939
816912 475725
372110 658764
524752 634255
625962 6305
732669 683709
399746 605557
257137 277620
319432 428231
20...

output:


135547

result:

ok 1 number(s): "135547"

Test #74:

score: 0
Accepted
time: 224ms
memory: 36740kb

input:

1000000
534839 694819
432827 429275
548088 236286
256982 484473
809794 79727
811855 638879
410265 804130
468148 598110
902525 577158
41027 946841
296702 843736
934804 162007
505844 258712
483762 23777
774503 10714
916761 903726
877225 479861
284733 304215
944170 653286
514372 731846
611188 692345
44...

output:


131958

result:

ok 1 number(s): "131958"

Test #75:

score: 0
Accepted
time: 198ms
memory: 36732kb

input:

1000000
707565 935156
528917 245891
11118 889543
674640 785839
298145 498391
463976 248963
753025 486517
745533 598155
813460 793992
300635 783368
263775 368588
43210 540811
703419 431312
695472 343428
792908 277930
307137 449821
343250 45514
632026 558690
837417 684608
748106 837964
49933 884791
70...

output:


130059

result:

ok 1 number(s): "130059"

Test #76:

score: 0
Accepted
time: 214ms
memory: 36740kb

input:

1000000
333361 618333
699269 478178
52039 190219
135953 708916
883661 630648
111740 855763
675306 698739
798576 194420
215110 538582
430800 489618
99864 657741
706758 988468
841917 739116
602179 720245
525956 701341
376257 729336
302061 223111
192903 975435
612963 443383
886057 244276
688702 429702
...

output:


128195

result:

ok 1 number(s): "128195"

Test #77:

score: 0
Accepted
time: 218ms
memory: 36684kb

input:

1000000
906212 751208
338600 710981
999274 858577
398329 407555
266577 187738
46023 580974
510841 156443
960439 852647
511917 391223
121134 37989
824478 748020
22750 705675
826025 951502
883352 699201
890647 385860
61623 851661
184034 818767
485436 899712
251653 199062
51094 635355
118895 711733
502...

output:


127206

result:

ok 1 number(s): "127206"

Test #78:

score: 0
Accepted
time: 235ms
memory: 36628kb

input:

1000000
948324 287999
326172 157033
635877 802043
221261 320171
643392 595379
987874 50075
985125 16679
117827 300088
487263 264626
995146 709793
759651 734003
891160 56721
897711 560805
621579 7069
499426 485184
909006 226396
609456 374854
197131 183081
515122 385424
398768 744796
540937 676337
778...

output:


126582

result:

ok 1 number(s): "126582"

Test #79:

score: 0
Accepted
time: 240ms
memory: 36696kb

input:

1000000
770310 940724
861003 906210
896615 108251
213927 622292
372897 29976
976989 601373
78682 357419
494814 919632
692834 677694
235056 724827
253488 292088
324387 986341
568019 692924
241696 379317
484563 939930
762888 588791
247088 600816
51761 866908
440231 542524
100545 521554
153660 681367
8...

output:


126275

result:

ok 1 number(s): "126275"

Test #80:

score: 0
Accepted
time: 245ms
memory: 36780kb

input:

1000000
380190 949422
766380 984233
119991 337510
222782 474859
662650 45350
586736 788193
539390 387772
641549 111929
377431 925004
514944 469196
103227 286171
405372 835249
607976 456655
603391 2011
515473 572806
340525 818372
318917 944530
903132 491821
220657 383531
200888 201652
255418 234543
3...

output:


122209

result:

ok 1 number(s): "122209"

Test #81:

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

input:

10
1 2
1 3
2 4
2 7
3 5
3 6
4 9
6 10
7 8

output:


1

result:

ok 1 number(s): "1"

Test #82:

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

input:

5
1 2
2 3
3 4
3 5

output:


1

result:

ok 1 number(s): "1"

Test #83:

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

input:

34
23 27
29 26
5 18
28 25
24 2
22 34
20 4
5 31
29 7
1 16
19 21
20 10
13 14
12 22
3 20
25 1
17 21
17 22
13 28
8 6
31 22
33 3
28 24
3 16
22 29
15 3
3 17
9 2
8 26
23 14
10 11
32 29
20 30

output:


4

result:

ok 1 number(s): "4"