QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#859655#9678. 网友小 Z 的树Zaunese100 ✓1024ms62948kbC++142.0kb2025-01-17 21:27:252025-01-17 21:27:56

Judging History

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

  • [2025-01-17 21:27:56]
  • 评测
  • 测评结果:100
  • 用时:1024ms
  • 内存:62948kb
  • [2025-01-17 21:27:25]
  • 提交

answer

//                      위대한    -    주의 만세!
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include"diameter.h"

#define fi first
#define se second
#define mkp std::make_pair
using llu=long long unsigned;
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}

std::pair<int,int> find_diameter(int sid,int N){
    if(N==1) return mkp(1,1);
    if(N==2) return mkp(1,2);
    if(N==3){
        return in(1,2,3)?mkp(2,3):(in(2,1,3)?mkp(1,3):mkp(1,2));
    }
    int x=1,y=2,z=0,t=0;
    std::vector<int> a(N+1,0);
    int mx=0;
    for(int i=1;i<=N;++i) if(i!=x&&i!=y){
        a[i]=query(i,x,y);
        if(!mx) mx=i;
        else if(a[i]>a[mx]) mx=i;
    }
    y=mx;
    //printf("%d %d %d %d\n",x,y,z,t);
    a=std::vector<int>(N+1,0);
    mx=0;
    for(int i=1;i<=N;++i) if(i!=x&&i!=y){
        a[i]=query(i,x,y);
        if(!mx) mx=i;
        else if(a[i]>a[mx]) mx=i;
    }
    z=mx;
    //printf("%d %d %d %d\n",x,y,z,t);
    a=std::vector<int>(N+1,0);
    mx=0;
    int mn=0;
    for(int i=1;i<=N;++i) if(i!=z&&i!=y){
        a[i]=query(i,z,y);
        if(!mx) mx=mn=i;
        else{
            if(a[i]>a[mx]) mx=i;
            if(a[i]<a[mn]) mn=i;
        }
    }
    x=mx;
    t=mn;

    //printf("%d %d %d %d\n",x,y,z,t);

    if(x==t) return mkp(y,z);
    if(!in(t,y,z)){
        if(query(x,t,z)>query(x,t,y)) return mkp(x,z);
        else return mkp(x,y);
    }

    int dyz=a[t]/2,dxyz=a[x]/2;
	int dyxt=query(y,x,t)/2;
	int dzxt=query(x,t,z)/2;
    int dxy,dxz;
    if(!in(t,x,y)){
        dxz=dzxt;
        dxy=dxyz*2-dyz-dzxt;
    }else{
        dxy=dyxt;
        dxz=dxyz*2-dyz-dyxt;
    }

    if(std::max({dyz,dxy,dxz})==dyz) return mkp(y,z);
    if(std::max({dyz,dxy,dxz})==dxy) return mkp(x,y);
    return mkp(x,z);
}

詳細信息

Subtask #1:

score: 16
Accepted

Test #1:

score: 16
Accepted
time: 2ms
memory: 14492kb

input:

1 100
25
1 3
2 18
3 8
4 18
5 14
6 22
7 18
8 10
9 11
10 12
11 25
12 16
13 11
14 17
15 17
16 25
17 2
18 20
19 18
20 12
21 1
22 17
23 14
24 1
50
1 37
2 27
3 10
4 25
5 16
6 17
7 10
8 36
9 16
10 6
11 48
12 2
13 28
14 30
15 10
16 44
17 31
18 1
19 6
20 7
21 30
22 42
23 45
24 23
25 27
26 39
27 45
28 48
29 4...

output:

correct

result:

ok Correct

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 15
Accepted
time: 46ms
memory: 21336kb

input:

2 2006
42
1 32
2 4
3 6
4 29
5 1
6 42
7 10
8 16
9 6
10 25
11 42
12 8
13 36
14 8
15 17
16 3
17 6
18 21
19 23
20 31
21 42
22 6
23 32
24 7
25 27
26 34
27 31
28 6
29 41
30 20
31 9
32 7
33 3
34 5
35 5
36 1
37 8
38 14
39 15
40 12
41 22
95
1 94
2 88
3 13
4 71
5 37
6 45
7 87
8 24
9 76
10 54
11 69
12 95
13 90...

output:

correct

result:

ok Correct

Test #3:

score: 15
Accepted
time: 356ms
memory: 27472kb

input:

2 100
10000
5442 1084
1084 8984
8984 3299
3299 6385
6385 6079
6079 6806
6806 2300
2300 2996
2996 1765
1765 257
257 5537
5537 2337
2337 5445
5445 2873
2873 336
336 6307
6307 4968
4968 8078
8078 9944
9944 5675
5675 7896
7896 5943
5943 2412
2412 7448
7448 7852
7852 1684
1684 3437
3437 3980
3980 1919
19...

output:

correct

result:

ok Correct

Test #4:

score: 15
Accepted
time: 385ms
memory: 27084kb

input:

2 100
10000
1 5915
2 3020
3 9265
4 5171
5 1304
6 6769
7 1914
8 4904
9 7545
10 2296
11 4189
12 3509
13 7725
14 133
15 4023
16 7720
17 2707
18 9553
19 5215
20 6984
21 4421
22 2279
23 33
24 4737
25 4205
26 9619
27 1848
28 4322
29 5602
30 1476
31 2636
32 8841
33 3701
34 590
35 8382
36 9625
37 240
38 311...

output:

correct

result:

ok Correct

Test #5:

score: 15
Accepted
time: 363ms
memory: 27136kb

input:

2 100
10000
9186 8585
8585 2991
9186 2522
2991 2727
2991 3356
8585 7483
3356 6258
3356 3554
2727 9199
2991 6593
2727 3223
3223 780
2727 1306
7483 6018
3223 2570
7483 826
6258 7695
6593 303
9199 8280
8280 3057
3223 2719
1306 3966
7695 7382
3966 8835
8280 983
7382 5734
8280 3094
3057 4999
2719 5934
73...

output:

correct

result:

ok Correct

Test #6:

score: 15
Accepted
time: 368ms
memory: 27164kb

input:

2 100
10000
258 225
225 9405
9405 2228
225 912
258 2001
2001 7782
9405 2373
258 747
2001 7685
747 1101
7782 7229
2228 5458
2228 9451
9451 2073
2073 7753
5458 2328
7753 1592
1101 6637
2328 5359
1101 4393
4393 8882
1592 928
4393 9422
6637 2468
7753 3759
4393 6763
5359 8404
9422 7471
8882 7360
8404 184...

output:

correct

result:

ok Correct

Test #7:

score: 15
Accepted
time: 361ms
memory: 27092kb

input:

2 100
10000
5715 7993
5715 6965
7993 426
6965 2015
426 1744
2015 9193
426 4406
1744 7821
7821 4607
426 1151
7821 1378
4607 999
7821 5563
1744 8800
4607 3167
7821 4424
4406 6427
8800 2796
5563 8767
6427 2096
2796 659
659 7524
8800 39
4424 2158
8767 1736
2796 4824
659 2410
2096 8710
7524 2078
8710 119...

output:

correct

result:

ok Correct

Test #8:

score: 15
Accepted
time: 290ms
memory: 31212kb

input:

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

output:

correct

result:

ok Correct

Subtask #3:

score: 5
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 5
Accepted
time: 80ms
memory: 25888kb

input:

3 2006
95
1 50
2 83
3 65
4 31
5 64
6 83
7 22
8 17
9 12
10 24
11 81
12 82
13 70
14 71
15 16
16 66
17 68
18 25
19 64
20 90
21 19
22 14
23 4
24 55
25 11
26 15
27 47
28 90
29 33
30 10
31 73
32 4
33 32
34 13
35 46
36 42
37 36
38 17
39 47
40 67
41 23
42 72
43 75
44 92
45 57
46 88
47 78
48 43
49 58
50 62
5...

output:

correct

result:

ok Correct

Test #10:

score: 5
Accepted
time: 470ms
memory: 32520kb

input:

3 50
20000
12483 13249
13249 6419
6419 18097
18097 17847
17847 2932
2932 14960
14960 6371
6371 3371
3371 18403
18403 18882
18882 16513
16513 13330
13330 7685
7685 2725
2725 9445
9445 10962
10962 6952
6952 5108
5108 12657
12657 4299
4299 9621
9621 4521
4521 16644
16644 14790
14790 15234
15234 13858
1...

output:

correct

result:

ok Correct

Test #11:

score: 5
Accepted
time: 481ms
memory: 31636kb

input:

3 50
20000
1 10511
2 8258
3 11981
4 12921
5 14758
6 443
7 5500
8 4105
9 15921
10 19586
11 6477
12 14217
13 9381
14 10767
15 6566
16 3232
17 18904
18 15280
19 17754
20 1743
21 994
22 16695
23 13403
24 2947
25 14089
26 19962
27 12998
28 4014
29 8751
30 8029
31 14686
32 8019
33 13808
34 852
35 2992
36 ...

output:

correct

result:

ok Correct

Test #12:

score: 5
Accepted
time: 452ms
memory: 29704kb

input:

3 50
20000
14783 6405
14783 997
14783 15183
6405 4079
14783 3959
6405 13688
13688 394
6405 18458
997 2652
2652 8182
6405 8855
13688 13569
3959 9652
18458 19932
3959 2233
13688 2925
2925 17109
9652 520
2652 3931
2925 12446
2233 17300
520 11989
17300 14352
17300 1490
14352 17585
17109 15867
3931 7306
...

output:

correct

result:

ok Correct

Test #13:

score: 5
Accepted
time: 453ms
memory: 31764kb

input:

3 50
20000
5219 5072
5072 18451
5219 1483
5219 6164
6164 11035
1483 9913
9913 10220
6164 6063
6164 2560
1483 987
6164 16481
16481 13784
6063 485
10220 11717
2560 16335
6063 19981
987 6387
13784 14504
2560 14762
16481 11230
13784 13201
14504 9437
14762 19951
6387 7610
16335 1501
9437 14901
9437 13391...

output:

correct

result:

ok Correct

Test #14:

score: 5
Accepted
time: 452ms
memory: 29736kb

input:

3 50
20000
11410 9893
11410 2259
11410 13823
2259 14136
9893 18639
2259 5699
9893 13085
9893 13095
2259 4627
5699 5572
13823 12950
13823 17350
12950 12984
4627 14584
5572 9511
13095 18547
17350 13655
17350 11614
14584 17057
5572 1023
13655 3546
17057 8142
1023 2641
17057 13187
13655 10323
11614 1419...

output:

correct

result:

ok Correct

Test #15:

score: 5
Accepted
time: 317ms
memory: 35460kb

input:

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

output:

correct

result:

ok Correct

Subtask #4:

score: 5
Accepted

Dependency #3:

100%
Accepted

Test #16:

score: 5
Accepted
time: 119ms
memory: 31420kb

input:

4 2006
72
1 11
2 33
3 63
4 45
5 70
6 23
7 41
8 51
9 63
10 71
11 56
12 36
13 55
14 1
15 45
16 68
17 37
18 65
19 1
20 42
21 16
22 27
23 1
24 14
25 4
26 13
27 52
28 34
29 28
30 72
31 43
32 13
33 47
34 6
35 26
36 69
37 16
38 9
39 47
40 6
41 10
42 50
43 28
44 9
45 35
46 28
47 51
48 68
49 59
50 26
51 10
5...

output:

correct

result:

ok Correct

Test #17:

score: 5
Accepted
time: 512ms
memory: 35596kb

input:

4 33
30000
14256 19392
19392 17693
17693 12064
12064 29690
29690 2629
2629 2231
2231 8291
8291 20777
20777 13056
13056 17592
17592 3521
3521 9564
9564 20486
20486 11910
11910 5841
5841 8074
8074 8949
8949 27794
27794 5140
5140 628
628 23696
23696 219
219 27931
27931 12329
12329 11380
11380 16340
163...

output:

correct

result:

ok Correct

Test #18:

score: 5
Accepted
time: 521ms
memory: 36192kb

input:

4 33
30000
1 10055
2 15066
3 26132
4 2602
5 25450
6 3181
7 10378
8 16011
9 14843
10 5467
11 23120
12 20330
13 4410
14 24149
15 1259
16 25325
17 5148
18 22993
19 14548
20 17083
21 21423
22 4431
23 2608
24 27414
25 7398
26 680
27 6389
28 7789
29 24276
30 23976
31 21652
32 14331
33 4244
34 2538
35 1511...

output:

correct

result:

ok Correct

Test #19:

score: 5
Accepted
time: 499ms
memory: 34324kb

input:

4 33
30000
5160 22570
5160 4162
22570 4564
22570 2953
22570 6160
2953 16958
5160 18469
18469 16390
4564 4820
4820 26260
4820 23921
4820 22416
16390 5064
18469 21384
4820 18969
22416 2213
18469 10791
23921 18801
2213 28618
23921 12934
12934 23199
2213 2731
23199 13937
18801 7907
18969 12659
2213 1006...

output:

correct

result:

ok Correct

Test #20:

score: 5
Accepted
time: 515ms
memory: 34252kb

input:

4 33
30000
5124 14169
14169 7693
14169 3148
7693 7827
7827 5425
14169 4462
7693 5036
7827 1840
5036 15358
3148 354
15358 25457
354 23612
5036 809
15358 28504
15358 220
28504 12793
1840 25908
354 240
25908 14658
354 12184
23612 25257
14658 26851
809 10856
12184 23643
14658 23748
23643 7400
7400 19133...

output:

correct

result:

ok Correct

Test #21:

score: 5
Accepted
time: 511ms
memory: 34412kb

input:

4 33
30000
16458 22215
22215 25117
16458 10098
16458 19468
19468 19780
22215 18948
25117 1930
10098 601
22215 28765
1930 28418
25117 12818
10098 29737
29737 8189
12818 2531
28765 23263
12818 20088
20088 3660
28765 3752
29737 2048
3752 10286
20088 14216
20088 5154
3752 12129
2531 5116
3660 12518
5116...

output:

correct

result:

ok Correct

Test #22:

score: 5
Accepted
time: 340ms
memory: 37804kb

input:

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

output:

correct

result:

ok Correct

Subtask #5:

score: 5
Accepted

Dependency #4:

100%
Accepted

Test #23:

score: 5
Accepted
time: 162ms
memory: 36492kb

input:

5 2006
74
1 63
2 63
3 55
4 35
5 36
6 63
7 64
8 71
9 61
10 47
11 18
12 62
13 41
14 59
15 70
16 27
17 5
18 30
19 59
20 65
21 28
22 41
23 18
24 20
25 14
26 4
27 63
28 17
29 37
30 49
31 7
32 64
33 2
34 7
35 32
36 22
37 7
38 26
39 46
40 18
41 37
42 73
43 19
44 53
45 15
46 20
47 53
48 63
49 10
50 15
51 15...

output:

correct

result:

ok Correct

Test #24:

score: 5
Accepted
time: 580ms
memory: 40660kb

input:

5 25
40000
9770 7780
7780 34738
34738 37985
37985 15685
15685 21772
21772 1975
1975 582
582 26341
26341 13165
13165 34397
34397 39627
39627 34769
34769 18282
18282 23951
23951 34185
34185 15227
15227 28159
28159 1721
1721 17784
17784 36525
36525 38137
38137 29531
29531 22379
22379 36276
36276 3637
3...

output:

correct

result:

ok Correct

Test #25:

score: 5
Accepted
time: 601ms
memory: 38724kb

input:

5 25
40000
1 19786
2 20270
3 26558
4 308
5 18939
6 28114
7 29876
8 25726
9 8597
10 26654
11 19829
12 1028
13 4133
14 4851
15 26521
16 29163
17 310
18 27981
19 19834
20 27717
21 30635
22 24263
23 20478
24 7257
25 3035
26 20922
27 17446
28 39771
29 3904
30 11759
31 18587
32 20761
33 12342
34 27898
35 ...

output:

correct

result:

ok Correct

Test #26:

score: 5
Accepted
time: 578ms
memory: 36860kb

input:

5 25
40000
36764 35314
36764 37104
36764 12118
35314 32376
37104 22392
22392 24470
32376 23023
23023 34964
37104 39669
22392 32311
22392 31856
32311 9326
31856 16319
23023 10898
31856 31172
10898 26464
31856 22435
34964 5426
32311 10612
22435 1868
10612 433
10898 6371
10612 27937
6371 10091
5426 274...

output:

correct

result:

ok Correct

Test #27:

score: 5
Accepted
time: 628ms
memory: 39044kb

input:

5 25
40000
10000 5625
5625 14082
14082 34314
34314 29412
14082 38558
29412 35886
35886 31474
5625 22366
35886 33342
22366 12865
38558 13915
35886 4966
29412 3655
33342 20958
13915 23834
4966 7351
20958 24278
3655 10661
4966 32288
12865 12551
32288 37871
32288 37180
20958 4257
32288 37808
24278 39254...

output:

correct

result:

ok Correct

Test #28:

score: 5
Accepted
time: 575ms
memory: 39068kb

input:

5 25
40000
27638 17632
17632 35387
35387 24098
35387 13326
24098 28923
13326 7854
24098 22355
13326 12236
35387 30495
24098 5269
24098 12357
28923 18620
22355 31349
28923 17802
30495 6723
22355 20054
17802 4285
18620 5098
20054 609
18620 17874
4285 19437
31349 30277
31349 32994
30277 23651
19437 283...

output:

correct

result:

ok Correct

Test #29:

score: 5
Accepted
time: 364ms
memory: 42384kb

input:

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

output:

correct

result:

ok Correct

Subtask #6:

score: 10
Accepted

Dependency #5:

100%
Accepted

Test #30:

score: 10
Accepted
time: 194ms
memory: 39520kb

input:

6 2006
79
1 62
2 71
3 52
4 23
5 22
6 12
7 65
8 32
9 45
10 67
11 48
12 37
13 67
14 8
15 43
16 65
17 37
18 55
19 47
20 55
21 6
22 23
23 71
24 54
25 10
26 22
27 70
28 56
29 27
30 74
31 37
32 65
33 7
34 26
35 63
36 13
37 22
38 40
39 50
40 19
41 72
42 79
43 76
44 51
45 27
46 17
47 53
48 47
49 63
50 16
51...

output:

correct

result:

ok Correct

Test #31:

score: 10
Accepted
time: 609ms
memory: 43780kb

input:

6 20
50000
3285 10412
10412 43006
43006 155
155 17821
17821 32499
32499 10047
10047 12804
12804 41225
41225 39582
39582 25546
25546 39164
39164 31225
31225 6444
6444 27823
27823 48791
48791 29070
29070 9568
9568 25857
25857 21241
21241 43335
43335 6900
6900 26523
26523 43337
43337 21557
21557 6101
6...

output:

correct

result:

ok Correct

Test #32:

score: 10
Accepted
time: 646ms
memory: 41300kb

input:

6 20
50000
1 41289
2 13163
3 36632
4 848
5 22658
6 3201
7 39605
8 23144
9 21285
10 48692
11 27642
12 7568
13 6462
14 7043
15 30486
16 16297
17 369
18 23604
19 15390
20 48771
21 16268
22 15519
23 5541
24 3583
25 34489
26 38470
27 42370
28 44533
29 30609
30 12722
31 44141
32 15534
33 33876
34 39951
35...

output:

correct

result:

ok Correct

Test #33:

score: 10
Accepted
time: 641ms
memory: 41716kb

input:

6 20
50000
39398 719
719 12720
719 15975
12720 3047
12720 25537
719 24303
39398 12630
25537 35767
12720 41387
25537 32950
15975 4413
4413 35611
35767 7871
7871 19497
35767 17824
4413 2055
35611 17927
7871 29485
35611 32724
29485 22408
7871 25996
25996 17000
22408 49112
32724 36924
32724 37250
22408 ...

output:

correct

result:

ok Correct

Test #34:

score: 10
Accepted
time: 676ms
memory: 41692kb

input:

6 20
50000
32533 28122
28122 35120
35120 47242
47242 8178
47242 31406
47242 28909
32533 5571
8178 32808
31406 41862
31406 19405
5571 28722
31406 48996
41862 810
19405 44645
19405 42059
5571 31749
31749 44442
41862 8963
810 34009
44645 15898
42059 29282
34009 47280
15898 7629
8963 42955
31749 12136
3...

output:

correct

result:

ok Correct

Test #35:

score: 10
Accepted
time: 684ms
memory: 41676kb

input:

6 20
50000
29242 3691
3691 14178
29242 15922
3691 39988
29242 39877
29242 14090
15922 37248
14090 8436
14090 6182
14090 5190
3691 5201
5190 13104
39877 35772
13104 8529
37248 43198
37248 47323
5190 4918
47323 49601
35772 14347
43198 47454
49601 29744
13104 43998
43198 49115
8529 43576
29744 32286
29...

output:

correct

result:

ok Correct

Test #36:

score: 10
Accepted
time: 382ms
memory: 44652kb

input:

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

output:

correct

result:

ok Correct

Subtask #7:

score: 14
Accepted

Dependency #6:

100%
Accepted

Test #37:

score: 14
Accepted
time: 299ms
memory: 44308kb

input:

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

output:

correct

result:

ok Correct

Test #38:

score: 14
Accepted
time: 667ms
memory: 46848kb

input:

7 16
60000
41210 10893
10893 8223
8223 52928
52928 35748
35748 56311
56311 53725
53725 39778
39778 1262
1262 7230
7230 52429
52429 11421
11421 38244
38244 43612
43612 57526
57526 43165
43165 37497
37497 5109
5109 40305
40305 34648
34648 40929
40929 12214
12214 23989
23989 59778
59778 25817
25817 292...

output:

correct

result:

ok Correct

Test #39:

score: 14
Accepted
time: 706ms
memory: 43796kb

input:

7 16
60000
1 29825
2 46514
3 18106
4 20053
5 17579
6 39845
7 52617
8 41529
9 8100
10 54570
11 1928
12 40720
13 34813
14 14212
15 25648
16 40983
17 5274
18 22938
19 240
20 37948
21 59013
22 47855
23 50954
24 17344
25 24250
26 11720
27 57042
28 12465
29 10693
30 28875
31 26359
32 25383
33 12846
34 424...

output:

correct

result:

ok Correct

Test #40:

score: 14
Accepted
time: 638ms
memory: 46272kb

input:

7 16
60000
13400 21995
13400 48038
48038 33107
33107 53013
48038 12436
33107 48036
21995 23362
48038 36772
23362 46929
21995 41860
48036 16742
48036 42026
23362 13946
41860 16962
36772 38744
13946 19023
42026 43857
41860 1873
16962 6932
19023 36784
16742 20719
43857 54536
54536 6906
19023 56657
5665...

output:

correct

result:

ok Correct

Test #41:

score: 14
Accepted
time: 676ms
memory: 46228kb

input:

7 16
60000
58798 44785
44785 52900
44785 8615
44785 23544
44785 45720
45720 25052
23544 58915
25052 20779
20779 3757
52900 29580
3757 27386
58915 9562
27386 54257
58915 11364
54257 2046
11364 40406
40406 17759
17759 45019
27386 45442
54257 34017
45442 46106
54257 55961
11364 30083
40406 58689
46106 ...

output:

correct

result:

ok Correct

Test #42:

score: 14
Accepted
time: 774ms
memory: 46112kb

input:

7 16
60000
34910 40855
34910 6093
6093 19639
34910 31757
34910 54815
34910 15522
15522 21499
21499 1497
6093 46351
34910 40394
46351 32419
6093 8962
46351 24258
54815 54281
54815 36714
8962 8117
36714 51546
1497 59083
32419 932
8117 27989
27989 35716
27989 34726
36714 58682
34726 41630
932 20809
811...

output:

correct

result:

ok Correct

Test #43:

score: 14
Accepted
time: 442ms
memory: 48972kb

input:

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

output:

correct

result:

ok Correct

Subtask #8:

score: 13
Accepted

Dependency #7:

100%
Accepted

Test #44:

score: 13
Accepted
time: 328ms
memory: 47196kb

input:

8 2006
88
1 14
2 88
3 80
4 85
5 53
6 36
7 65
8 72
9 26
10 74
11 18
12 71
13 22
14 23
15 60
16 20
17 51
18 52
19 49
20 18
21 53
22 50
23 57
24 8
25 57
26 59
27 87
28 23
29 18
30 73
31 64
32 35
33 43
34 5
35 7
36 62
37 66
38 54
39 35
40 21
41 88
42 17
43 75
44 49
45 63
46 16
47 19
48 41
49 2
50 56
51 ...

output:

correct

result:

ok Correct

Test #45:

score: 13
Accepted
time: 835ms
memory: 51596kb

input:

8 14
70000
10221 9711
9711 48517
48517 39746
39746 37766
37766 3737
3737 35298
35298 21342
21342 64821
64821 62278
62278 7802
7802 54367
54367 13445
13445 7293
7293 7709
7709 46872
46872 26039
26039 4251
4251 44560
44560 30927
30927 27668
27668 41939
41939 17819
17819 48538
48538 17688
17688 20109
2...

output:

correct

result:

ok Correct

Test #46:

score: 13
Accepted
time: 806ms
memory: 48220kb

input:

8 14
70000
1 45318
2 55517
3 7549
4 32062
5 69762
6 36750
7 51379
8 68358
9 7499
10 57775
11 28266
12 10603
13 62024
14 51494
15 54237
16 3734
17 15840
18 56008
19 7039
20 40772
21 15808
22 47810
23 50626
24 2992
25 4496
26 55255
27 37913
28 53748
29 12876
30 13177
31 30977
32 18187
33 57295
34 4466...

output:

correct

result:

ok Correct

Test #47:

score: 13
Accepted
time: 817ms
memory: 48848kb

input:

8 14
70000
59417 8197
59417 40047
59417 38179
59417 21214
21214 3881
38179 29456
8197 51890
40047 60285
60285 37223
40047 54925
29456 31170
40047 47443
37223 65558
47443 42697
37223 18946
65558 31425
47443 29074
31425 2324
18946 7560
54925 34479
31170 58765
47443 27489
29074 42899
18946 3112
34479 5...

output:

correct

result:

ok Correct

Test #48:

score: 13
Accepted
time: 824ms
memory: 50696kb

input:

8 14
70000
51612 20042
51612 17538
51612 36615
17538 35288
17538 47124
51612 16692
35288 33006
20042 23500
16692 55265
55265 66476
33006 38124
55265 51674
23500 53246
23500 67263
33006 7610
53246 38100
51674 128
7610 32805
38100 57932
53246 31344
32805 58420
128 29324
67263 39818
7610 26168
128 3578...

output:

correct

result:

ok Correct

Test #49:

score: 13
Accepted
time: 789ms
memory: 48812kb

input:

8 14
70000
3528 20320
3528 13494
13494 2201
3528 34764
3528 45471
45471 1196
34764 38811
3528 42612
45471 50597
13494 49770
1196 37725
37725 66956
2201 64845
50597 40578
45471 7879
50597 39737
49770 50272
50272 61947
64845 51615
64845 41853
7879 68961
41853 54489
61947 61459
51615 1595
1595 39513
50...

output:

correct

result:

ok Correct

Test #50:

score: 13
Accepted
time: 480ms
memory: 51744kb

input:

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

output:

correct

result:

ok Correct

Subtask #9:

score: 6
Accepted

Dependency #8:

100%
Accepted

Test #51:

score: 6
Accepted
time: 393ms
memory: 53652kb

input:

9 2006
27
1 15
2 3
3 23
4 16
5 15
6 24
7 22
8 12
9 2
10 4
11 4
12 7
13 25
14 26
15 25
16 18
17 23
18 19
19 22
20 4
21 4
22 27
23 7
24 11
25 21
26 21
67
1 67
2 5
3 43
4 64
5 33
6 16
7 41
8 49
9 8
10 45
11 7
12 55
13 20
14 2
15 53
16 10
17 46
18 55
19 17
20 21
21 49
22 20
23 39
24 39
25 8
26 23
27 15
...

output:

correct

result:

ok Correct

Test #52:

score: 6
Accepted
time: 822ms
memory: 57028kb

input:

9 12
80000
62788 36475
36475 15059
15059 20706
20706 46870
46870 22120
22120 32748
32748 19741
19741 19711
19711 20444
20444 54858
54858 36422
36422 46798
46798 76166
76166 37025
37025 18977
18977 21902
21902 56175
56175 35748
35748 10897
10897 13373
13373 38874
38874 70823
70823 1873
1873 54761
547...

output:

correct

result:

ok Correct

Test #53:

score: 6
Accepted
time: 863ms
memory: 52764kb

input:

9 12
80000
1 52423
2 21224
3 27660
4 55617
5 17821
6 18680
7 60372
8 11047
9 15742
10 53678
11 40295
12 3593
13 38842
14 73211
15 5820
16 51096
17 22486
18 29305
19 68285
20 35027
21 76988
22 3055
23 79742
24 25650
25 60525
26 17581
27 43980
28 36431
29 57712
30 69666
31 53167
32 42201
33 10184
34 1...

output:

correct

result:

ok Correct

Test #54:

score: 6
Accepted
time: 896ms
memory: 53444kb

input:

9 12
80000
2512 3844
3844 18352
18352 23312
23312 17737
23312 50667
2512 50716
50667 14292
3844 59208
3844 13596
59208 49034
50716 29676
23312 11071
11071 18120
50716 16734
13596 58710
18120 57875
14292 71027
71027 39289
71027 55813
58710 33606
57875 42003
39289 59888
59888 69572
59888 70089
55813 2...

output:

correct

result:

ok Correct

Test #55:

score: 6
Accepted
time: 842ms
memory: 53424kb

input:

9 12
80000
40377 37648
37648 52275
37648 77079
40377 63782
52275 25933
52275 41307
40377 27465
52275 57043
25933 16978
57043 42320
37648 52050
16978 54548
16978 75200
27465 53838
27465 7646
57043 47728
54548 77957
53838 3357
16978 16731
75200 42729
7646 40024
47728 1900
42729 8792
16731 18684
47728 ...

output:

correct

result:

ok Correct

Test #56:

score: 6
Accepted
time: 912ms
memory: 53488kb

input:

9 12
80000
10681 34344
34344 60291
60291 24174
24174 22379
22379 40363
10681 48650
22379 221
24174 41788
48650 74206
24174 3565
48650 44901
40363 64402
221 4357
4357 79146
64402 25042
74206 73951
41788 30196
44901 46679
74206 59572
44901 11571
44901 10516
4357 37851
25042 27067
73951 53405
73951 472...

output:

correct

result:

ok Correct

Test #57:

score: 6
Accepted
time: 547ms
memory: 55860kb

input:

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

output:

correct

result:

ok Correct

Subtask #10:

score: 6
Accepted

Dependency #9:

100%
Accepted

Test #58:

score: 6
Accepted
time: 489ms
memory: 58568kb

input:

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

output:

correct

result:

ok Correct

Test #59:

score: 6
Accepted
time: 937ms
memory: 61952kb

input:

10 11
90000
60543 58629
58629 43127
43127 70666
70666 14468
14468 63906
63906 22947
22947 54441
54441 38163
38163 48644
48644 19045
19045 60308
60308 22311
22311 26201
26201 30096
30096 81575
81575 82798
82798 63151
63151 61503
61503 62085
62085 17670
17670 45356
45356 46738
46738 27994
27994 64586
...

output:

correct

result:

ok Correct

Test #60:

score: 6
Accepted
time: 904ms
memory: 55108kb

input:

10 11
90000
1 55553
2 46021
3 82069
4 30698
5 71280
6 19390
7 87236
8 44444
9 10933
10 24184
11 25064
12 72983
13 60908
14 2086
15 11327
16 1521
17 72662
18 77271
19 16336
20 16508
21 59528
22 13047
23 17971
24 6233
25 17421
26 13242
27 60660
28 25863
29 57781
30 6033
31 14978
32 83506
33 66184
34 2...

output:

correct

result:

ok Correct

Test #61:

score: 6
Accepted
time: 921ms
memory: 55952kb

input:

10 11
90000
59079 85707
85707 7486
85707 61424
85707 21367
59079 5822
7486 68949
7486 29642
29642 49730
7486 43411
43411 79852
43411 36815
43411 38821
21367 277
49730 51236
36815 70467
38821 71236
51236 49868
71236 26987
51236 48478
70467 10119
71236 25645
25645 56070
277 85305
26987 8285
71236 4715...

output:

correct

result:

ok Correct

Test #62:

score: 6
Accepted
time: 923ms
memory: 55876kb

input:

10 11
90000
66753 23194
23194 75135
23194 42080
23194 49290
23194 33846
23194 22215
75135 41756
42080 5462
75135 34850
33846 74068
5462 43102
41756 14752
43102 41309
41756 75960
41309 18076
75960 46286
18076 89629
43102 64126
18076 30551
64126 62497
75960 52749
14752 72655
52749 6732
62497 43457
726...

output:

correct

result:

ok Correct

Test #63:

score: 6
Accepted
time: 935ms
memory: 58056kb

input:

10 11
90000
64551 70942
64551 74781
70942 42918
70942 62043
62043 8580
74781 51810
74781 65624
74781 53805
74781 59645
70942 25088
65624 12966
53805 42972
62043 67751
65624 41755
65624 40703
40703 1827
53805 20276
41755 5831
20276 31509
42972 2910
1827 59512
5831 61932
40703 12112
40703 72391
72391 ...

output:

correct

result:

ok Correct

Test #64:

score: 6
Accepted
time: 574ms
memory: 58600kb

input:

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

output:

correct

result:

ok Correct

Subtask #11:

score: 5
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Dependency #10:

100%
Accepted

Test #65:

score: 5
Accepted
time: 534ms
memory: 59932kb

input:

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

output:

correct

result:

ok Correct

Test #66:

score: 5
Accepted
time: 966ms
memory: 62948kb

input:

11 10
100000
66530 68809
68809 23016
23016 41136
41136 98521
98521 59427
59427 59351
59351 79241
79241 13963
13963 98439
98439 68236
68236 93319
93319 14234
14234 18256
18256 61583
61583 60474
60474 26839
26839 89976
89976 18845
18845 61892
61892 70228
70228 39944
39944 73646
73646 79112
79112 33849...

output:

correct

result:

ok Correct

Test #67:

score: 5
Accepted
time: 1024ms
memory: 57728kb

input:

11 10
100000
1 19374
2 43249
3 83367
4 37045
5 81190
6 98588
7 20679
8 33216
9 8653
10 16046
11 14405
12 43070
13 14948
14 18
15 38172
16 7285
17 2059
18 36774
19 44597
20 89325
21 50217
22 78041
23 78274
24 65029
25 45245
26 1534
27 16171
28 80338
29 75542
30 43174
31 21125
32 27395
33 62690
34 740...

output:

correct

result:

ok Correct

Test #68:

score: 5
Accepted
time: 1017ms
memory: 58520kb

input:

11 10
100000
79745 133
133 39684
39684 47075
39684 36215
39684 31147
133 30672
36215 73214
36215 29834
79745 65417
47075 33603
65417 79847
73214 72533
30672 51457
33603 49249
30672 1955
30672 81458
73214 20846
29834 9333
79847 85683
51457 93219
93219 22256
9333 96988
85683 4425
85683 76421
81458 436...

output:

correct

result:

ok Correct

Test #69:

score: 5
Accepted
time: 967ms
memory: 58480kb

input:

11 10
100000
65755 69315
65755 93902
93902 88124
88124 74241
69315 41880
65755 35614
88124 99076
88124 167
167 63808
74241 44557
44557 93980
74241 76017
41880 90563
76017 36380
63808 92243
35614 64510
44557 75190
93980 81778
76017 58389
75190 97331
93980 68907
92243 37353
97331 27456
27456 87837
878...

output:

correct

result:

ok Correct

Test #70:

score: 5
Accepted
time: 982ms
memory: 58552kb

input:

11 10
100000
30954 92791
92791 44156
92791 20902
92791 59804
20902 19497
92791 16777
19497 21117
20902 87586
87586 16467
44156 74779
44156 33686
21117 83774
19497 24918
19497 87496
33686 89618
87496 15033
15033 44524
74779 77699
89618 35131
24918 70421
44524 73150
77699 8277
73150 40580
15033 56321
...

output:

correct

result:

ok Correct

Test #71:

score: 5
Accepted
time: 613ms
memory: 60908kb

input:

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

output:

correct

result:

ok Correct