QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#714729#8269. Minequakemakrav41 1891ms4520kbC++201.4kb2024-11-06 04:04:572024-11-06 04:05:01

Judging History

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

  • [2024-11-06 04:05:01]
  • 评测
  • 测评结果:41
  • 用时:1891ms
  • 内存:4520kb
  • [2024-11-06 04:04:57]
  • 提交

answer

#include <bits/stdc++.h>
#include <cassert>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second
#define int ll

mt19937 rnd(time(NULL));
template<typename T>
void shuf(vector<T>& a) {
    for (int i = 1; i < sz(a); i++) swap(a[i], a[rnd() % (i + 1)]);
}

void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        g[u].pb(v);
        g[v].pb(u);
    }

    auto dfs = [&](int v, int p, auto&&self) -> pair<int, int> {
        int sm_subs = 0, sm_dp = 0, siz = 1;
        for (int u : g[v]) {
            if (u != p) {
                auto [subdp, newsiz] = self(u, v, self);
                siz += newsiz;
                sm_dp += subdp + newsiz + 2 * sm_subs * newsiz;
                sm_subs += newsiz;
            }
        }
        return {sm_dp, siz};
    };
    int ans = 1e18;
    for (int i = 0; i < n; i++) ans = min(ans, dfs(i, i, dfs).first);
    cout << ans << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false);
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 18
Accepted
time: 0ms
memory: 3620kb

input:

2
1 2

output:

1

result:

ok single line: '1'

Test #2:

score: 18
Accepted
time: 0ms
memory: 3576kb

input:

100
11 38
22 77
15 96
32 98
44 72
40 80
36 38
24 34
54 84
22 62
4 8
4 27
88 95
43 83
23 87
48 85
20 76
28 95
66 74
37 40
1 71
66 67
52 54
28 60
7 32
12 47
6 83
73 85
45 94
26 35
18 35
52 81
9 74
1 14
61 70
49 55
16 63
59 67
68 81
13 51
31 63
82 92
73 82
42 91
25 100
57 59
53 58
23 33
14 69
72 98
6 7...

output:

4950

result:

ok single line: '4950'

Test #3:

score: 18
Accepted
time: 12ms
memory: 3780kb

input:

1000
456 460
231 501
167 987
355 458
513 745
648 839
405 771
544 908
550 780
247 462
490 968
340 832
354 593
149 984
219 329
139 419
187 353
611 997
21 52
265 700
656 907
648 801
631 754
306 999
79 788
50 372
228 719
383 824
810 860
744 882
271 597
381 469
71 538
590 715
165 536
275 426
736 923
460 ...

output:

499500

result:

ok single line: '499500'

Test #4:

score: 18
Accepted
time: 11ms
memory: 3720kb

input:

999
373 839
435 715
841 962
100 130
434 681
646 725
33 580
188 250
539 937
377 868
174 780
215 708
416 900
85 451
738 884
187 299
380 535
175 437
43 122
342 888
562 681
287 569
114 146
590 894
476 952
927 950
502 522
226 270
300 336
176 997
538 915
634 798
360 673
413 943
12 945
619 685
103 196
301 ...

output:

498501

result:

ok single line: '498501'

Test #5:

score: 18
Accepted
time: 1891ms
memory: 4520kb

input:

10000
2478 7912
6084 6327
6138 7981
4307 7844
7336 7751
2033 5179
7681 9457
1937 9759
3179 8668
5807 9140
1393 5001
7092 7269
2949 6914
4827 8482
2076 4009
7719 8871
4555 8189
3200 4462
1027 9388
9 8506
654 8215
3785 7387
7876 9311
797 4946
519 9517
3063 7059
58 6852
217 5922
880 8300
55 2862
6263 7...

output:

49995000

result:

ok single line: '49995000'

Test #6:

score: 0
Time Limit Exceeded

input:

100000
63447 81769
10518 29951
51930 83828
12279 87657
8773 18966
46656 48966
62722 89892
69517 93765
58105 60105
982 94407
791 54257
53876 80692
66742 74816
23323 76655
67885 92952
8403 85783
52402 87875
15846 38499
10650 18431
30208 32962
37083 98919
87323 92004
26540 58217
7398 36425
26815 63605
...

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 20
Accepted

Test #31:

score: 20
Accepted
time: 0ms
memory: 3948kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #32:

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

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #33:

score: 20
Accepted
time: 0ms
memory: 3848kb

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #34:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #35:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #36:

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

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #37:

score: 20
Accepted
time: 0ms
memory: 3692kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #38:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #39:

score: 20
Accepted
time: 0ms
memory: 3628kb

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #40:

score: 20
Accepted
time: 0ms
memory: 3752kb

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #41:

score: 20
Accepted
time: 0ms
memory: 3752kb

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #42:

score: 20
Accepted
time: 0ms
memory: 3760kb

input:

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

output:

21

result:

ok single line: '21'

Test #43:

score: 20
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

31

result:

ok single line: '31'

Test #44:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

22

result:

ok single line: '22'

Test #45:

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

input:

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

output:

23

result:

ok single line: '23'

Test #46:

score: 20
Accepted
time: 0ms
memory: 3944kb

input:

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

output:

24

result:

ok single line: '24'

Test #47:

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

input:

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

output:

26

result:

ok single line: '26'

Test #48:

score: 20
Accepted
time: 0ms
memory: 3720kb

input:

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

output:

25

result:

ok single line: '25'

Test #49:

score: 20
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

28

result:

ok single line: '28'

Test #50:

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

input:

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

output:

25

result:

ok single line: '25'

Test #51:

score: 20
Accepted
time: 0ms
memory: 3756kb

input:

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

output:

26

result:

ok single line: '26'

Test #52:

score: 20
Accepted
time: 0ms
memory: 3612kb

input:

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

output:

27

result:

ok single line: '27'

Test #53:

score: 20
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

28

result:

ok single line: '28'

Test #54:

score: 20
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

33

result:

ok single line: '33'

Test #55:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

34

result:

ok single line: '34'

Test #56:

score: 20
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

36

result:

ok single line: '36'

Test #57:

score: 20
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

35

result:

ok single line: '35'

Test #58:

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

input:

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

output:

40

result:

ok single line: '40'

Test #59:

score: 20
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

37

result:

ok single line: '37'

Test #60:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

35

result:

ok single line: '35'

Test #61:

score: 20
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

36

result:

ok single line: '36'

Test #62:

score: 20
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

39

result:

ok single line: '39'

Test #63:

score: 20
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

36

result:

ok single line: '36'

Test #64:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

29

result:

ok single line: '29'

Test #65:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

37

result:

ok single line: '37'

Test #66:

score: 20
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

38

result:

ok single line: '38'

Test #67:

score: 20
Accepted
time: 0ms
memory: 3696kb

input:

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

output:

43

result:

ok single line: '43'

Test #68:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

34

result:

ok single line: '34'

Test #69:

score: 20
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

30

result:

ok single line: '30'

Test #70:

score: 20
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

33

result:

ok single line: '33'

Test #71:

score: 20
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

34

result:

ok single line: '34'

Test #72:

score: 20
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

31

result:

ok single line: '31'

Test #73:

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

input:

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

output:

31

result:

ok single line: '31'

Test #74:

score: 20
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

32

result:

ok single line: '32'

Test #75:

score: 20
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

32

result:

ok single line: '32'

Test #76:

score: 20
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

36

result:

ok single line: '36'

Test #77:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

46

result:

ok single line: '46'

Test #78:

score: 20
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

45

result:

ok single line: '45'

Test #79:

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

input:

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

output:

46

result:

ok single line: '46'

Test #80:

score: 20
Accepted
time: 0ms
memory: 3756kb

input:

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

output:

40

result:

ok single line: '40'

Test #81:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

41

result:

ok single line: '41'

Test #82:

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

input:

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

output:

43

result:

ok single line: '43'

Test #83:

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

input:

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

output:

42

result:

ok single line: '42'

Test #84:

score: 20
Accepted
time: 1ms
memory: 3848kb

input:

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

output:

44

result:

ok single line: '44'

Test #85:

score: 20
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

45

result:

ok single line: '45'

Test #86:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

45

result:

ok single line: '45'

Test #87:

score: 20
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

37

result:

ok single line: '37'

Test #88:

score: 20
Accepted
time: 0ms
memory: 3940kb

input:

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

output:

46

result:

ok single line: '46'

Test #89:

score: 20
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

42

result:

ok single line: '42'

Test #90:

score: 20
Accepted
time: 0ms
memory: 3848kb

input:

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

output:

43

result:

ok single line: '43'

Test #91:

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

input:

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

output:

42

result:

ok single line: '42'

Test #92:

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

input:

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

output:

43

result:

ok single line: '43'

Test #93:

score: 20
Accepted
time: 0ms
memory: 3852kb

input:

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

output:

43

result:

ok single line: '43'

Test #94:

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

input:

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

output:

44

result:

ok single line: '44'

Test #95:

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

input:

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

output:

44

result:

ok single line: '44'

Test #96:

score: 20
Accepted
time: 0ms
memory: 3944kb

input:

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

output:

45

result:

ok single line: '45'

Test #97:

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

input:

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

output:

46

result:

ok single line: '46'

Test #98:

score: 20
Accepted
time: 0ms
memory: 3916kb

input:

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

output:

38

result:

ok single line: '38'

Test #99:

score: 20
Accepted
time: 0ms
memory: 3692kb

input:

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

output:

48

result:

ok single line: '48'

Test #100:

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

input:

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

output:

47

result:

ok single line: '47'

Test #101:

score: 20
Accepted
time: 0ms
memory: 3928kb

input:

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

output:

50

result:

ok single line: '50'

Test #102:

score: 20
Accepted
time: 0ms
memory: 3756kb

input:

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

output:

49

result:

ok single line: '49'

Test #103:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

47

result:

ok single line: '47'

Test #104:

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

input:

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

output:

48

result:

ok single line: '48'

Test #105:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

53

result:

ok single line: '53'

Test #106:

score: 20
Accepted
time: 0ms
memory: 3584kb

input:

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

output:

47

result:

ok single line: '47'

Test #107:

score: 20
Accepted
time: 0ms
memory: 3692kb

input:

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

output:

50

result:

ok single line: '50'

Test #108:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

48

result:

ok single line: '48'

Test #109:

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

input:

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

output:

39

result:

ok single line: '39'

Test #110:

score: 20
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

49

result:

ok single line: '49'

Test #111:

score: 20
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

52

result:

ok single line: '52'

Test #112:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #113:

score: 20
Accepted
time: 0ms
memory: 3692kb

input:

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

output:

48

result:

ok single line: '48'

Test #114:

score: 20
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

49

result:

ok single line: '49'

Test #115:

score: 20
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

50

result:

ok single line: '50'

Test #116:

score: 20
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

51

result:

ok single line: '51'

Test #117:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

57

result:

ok single line: '57'

Test #118:

score: 20
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

39

result:

ok single line: '39'

Test #119:

score: 20
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

40

result:

ok single line: '40'

Test #120:

score: 20
Accepted
time: 0ms
memory: 3948kb

input:

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

output:

43

result:

ok single line: '43'

Test #121:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

42

result:

ok single line: '42'

Test #122:

score: 20
Accepted
time: 0ms
memory: 3948kb

input:

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

output:

41

result:

ok single line: '41'

Test #123:

score: 20
Accepted
time: 0ms
memory: 3612kb

input:

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

output:

45

result:

ok single line: '45'

Test #124:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #125:

score: 20
Accepted
time: 0ms
memory: 3688kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #4:

score: 21
Accepted

Dependency #3:

100%
Accepted

Test #126:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

3
1 2
1 3

output:

3

result:

ok single line: '3'

Test #127:

score: 21
Accepted
time: 0ms
memory: 3844kb

input:

4
1 2
2 3
1 4

output:

6

result:

ok single line: '6'

Test #128:

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

input:

5
1 2
2 3
1 4
4 5

output:

10

result:

ok single line: '10'

Test #129:

score: 21
Accepted
time: 0ms
memory: 3916kb

input:

5
1 2
2 3
1 4
1 5

output:

11

result:

ok single line: '11'

Test #130:

score: 21
Accepted
time: 0ms
memory: 3948kb

input:

5
1 2
1 3
1 4
1 5

output:

13

result:

ok single line: '13'

Test #131:

score: 21
Accepted
time: 0ms
memory: 3692kb

input:

6
1 2
2 3
1 5
3 4
5 6

output:

15

result:

ok single line: '15'

Test #132:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

16

result:

ok single line: '16'

Test #133:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

6
1 2
2 3
2 4
1 5
1 6

output:

19

result:

ok single line: '19'

Test #134:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

6
1 2
2 3
1 4
1 6
4 5

output:

17

result:

ok single line: '17'

Test #135:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

6
1 2
2 3
1 4
1 5
1 6

output:

18

result:

ok single line: '18'

Test #136:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

6
1 2
1 3
1 4
1 5
1 6

output:

21

result:

ok single line: '21'

Test #137:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

21

result:

ok single line: '21'

Test #138:

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

input:

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

output:

31

result:

ok single line: '31'

Test #139:

score: 21
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

22

result:

ok single line: '22'

Test #140:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

23

result:

ok single line: '23'

Test #141:

score: 21
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

24

result:

ok single line: '24'

Test #142:

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

input:

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

output:

26

result:

ok single line: '26'

Test #143:

score: 21
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

25

result:

ok single line: '25'

Test #144:

score: 21
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

28

result:

ok single line: '28'

Test #145:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

25

result:

ok single line: '25'

Test #146:

score: 21
Accepted
time: 0ms
memory: 3920kb

input:

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

output:

26

result:

ok single line: '26'

Test #147:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

27

result:

ok single line: '27'

Test #148:

score: 21
Accepted
time: 0ms
memory: 3752kb

input:

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

output:

28

result:

ok single line: '28'

Test #149:

score: 21
Accepted
time: 0ms
memory: 3796kb

input:

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

output:

33

result:

ok single line: '33'

Test #150:

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

input:

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

output:

34

result:

ok single line: '34'

Test #151:

score: 21
Accepted
time: 0ms
memory: 3692kb

input:

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

output:

36

result:

ok single line: '36'

Test #152:

score: 21
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

35

result:

ok single line: '35'

Test #153:

score: 21
Accepted
time: 0ms
memory: 3920kb

input:

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

output:

40

result:

ok single line: '40'

Test #154:

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

input:

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

output:

37

result:

ok single line: '37'

Test #155:

score: 21
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

35

result:

ok single line: '35'

Test #156:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

36

result:

ok single line: '36'

Test #157:

score: 21
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

39

result:

ok single line: '39'

Test #158:

score: 21
Accepted
time: 0ms
memory: 3760kb

input:

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

output:

36

result:

ok single line: '36'

Test #159:

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

input:

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

output:

29

result:

ok single line: '29'

Test #160:

score: 21
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

37

result:

ok single line: '37'

Test #161:

score: 21
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

38

result:

ok single line: '38'

Test #162:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

43

result:

ok single line: '43'

Test #163:

score: 21
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

34

result:

ok single line: '34'

Test #164:

score: 21
Accepted
time: 0ms
memory: 3940kb

input:

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

output:

30

result:

ok single line: '30'

Test #165:

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

input:

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

output:

33

result:

ok single line: '33'

Test #166:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

34

result:

ok single line: '34'

Test #167:

score: 21
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

31

result:

ok single line: '31'

Test #168:

score: 21
Accepted
time: 1ms
memory: 3624kb

input:

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

output:

31

result:

ok single line: '31'

Test #169:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

32

result:

ok single line: '32'

Test #170:

score: 21
Accepted
time: 0ms
memory: 3720kb

input:

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

output:

32

result:

ok single line: '32'

Test #171:

score: 21
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

36

result:

ok single line: '36'

Test #172:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

46

result:

ok single line: '46'

Test #173:

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

input:

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

output:

45

result:

ok single line: '45'

Test #174:

score: 21
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

46

result:

ok single line: '46'

Test #175:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

40

result:

ok single line: '40'

Test #176:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

41

result:

ok single line: '41'

Test #177:

score: 21
Accepted
time: 0ms
memory: 3752kb

input:

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

output:

43

result:

ok single line: '43'

Test #178:

score: 21
Accepted
time: 0ms
memory: 3692kb

input:

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

output:

42

result:

ok single line: '42'

Test #179:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

44

result:

ok single line: '44'

Test #180:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

45

result:

ok single line: '45'

Test #181:

score: 21
Accepted
time: 0ms
memory: 3948kb

input:

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

output:

45

result:

ok single line: '45'

Test #182:

score: 21
Accepted
time: 0ms
memory: 3944kb

input:

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

output:

37

result:

ok single line: '37'

Test #183:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

46

result:

ok single line: '46'

Test #184:

score: 21
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

42

result:

ok single line: '42'

Test #185:

score: 21
Accepted
time: 0ms
memory: 3732kb

input:

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

output:

43

result:

ok single line: '43'

Test #186:

score: 21
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

42

result:

ok single line: '42'

Test #187:

score: 21
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

43

result:

ok single line: '43'

Test #188:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

43

result:

ok single line: '43'

Test #189:

score: 21
Accepted
time: 0ms
memory: 3688kb

input:

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

output:

44

result:

ok single line: '44'

Test #190:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

44

result:

ok single line: '44'

Test #191:

score: 21
Accepted
time: 0ms
memory: 3696kb

input:

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

output:

45

result:

ok single line: '45'

Test #192:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

46

result:

ok single line: '46'

Test #193:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

38

result:

ok single line: '38'

Test #194:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

48

result:

ok single line: '48'

Test #195:

score: 21
Accepted
time: 0ms
memory: 3752kb

input:

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

output:

47

result:

ok single line: '47'

Test #196:

score: 21
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

50

result:

ok single line: '50'

Test #197:

score: 21
Accepted
time: 0ms
memory: 3908kb

input:

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

output:

49

result:

ok single line: '49'

Test #198:

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

input:

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

output:

47

result:

ok single line: '47'

Test #199:

score: 21
Accepted
time: 0ms
memory: 3684kb

input:

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

output:

48

result:

ok single line: '48'

Test #200:

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

input:

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

output:

53

result:

ok single line: '53'

Test #201:

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

input:

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

output:

47

result:

ok single line: '47'

Test #202:

score: 21
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

50

result:

ok single line: '50'

Test #203:

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

input:

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

output:

48

result:

ok single line: '48'

Test #204:

score: 21
Accepted
time: 0ms
memory: 3944kb

input:

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

output:

39

result:

ok single line: '39'

Test #205:

score: 21
Accepted
time: 0ms
memory: 3740kb

input:

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

output:

49

result:

ok single line: '49'

Test #206:

score: 21
Accepted
time: 0ms
memory: 3756kb

input:

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

output:

52

result:

ok single line: '52'

Test #207:

score: 21
Accepted
time: 0ms
memory: 3624kb

input:

3
1 2
2 3

output:

3

result:

ok single line: '3'

Test #208:

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

input:

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

output:

48

result:

ok single line: '48'

Test #209:

score: 21
Accepted
time: 0ms
memory: 3924kb

input:

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

output:

49

result:

ok single line: '49'

Test #210:

score: 21
Accepted
time: 0ms
memory: 3720kb

input:

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

output:

50

result:

ok single line: '50'

Test #211:

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

input:

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

output:

51

result:

ok single line: '51'

Test #212:

score: 21
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

57

result:

ok single line: '57'

Test #213:

score: 21
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

39

result:

ok single line: '39'

Test #214:

score: 21
Accepted
time: 0ms
memory: 3676kb

input:

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

output:

40

result:

ok single line: '40'

Test #215:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

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

output:

43

result:

ok single line: '43'

Test #216:

score: 21
Accepted
time: 0ms
memory: 3584kb

input:

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

output:

42

result:

ok single line: '42'

Test #217:

score: 21
Accepted
time: 0ms
memory: 3576kb

input:

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

output:

41

result:

ok single line: '41'

Test #218:

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

input:

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

output:

45

result:

ok single line: '45'

Test #219:

score: 21
Accepted
time: 6ms
memory: 3724kb

input:

1000
924 985
926 985
924 987
904 926
739 904
912 985
685 912
67 926
620 926
77 739
77 860
635 926
900 985
551 924
900 986
53 985
402 912
73 985
432 551
113 987
648 926
265 912
737 912
432 759
432 823
739 841
549 823
145 549
724 985
40 145
767 985
429 648
67 936
444 900
245 860
265 304
429 613
46 245...

output:

982402

result:

ok single line: '982402'

Test #220:

score: 21
Accepted
time: 7ms
memory: 3904kb

input:

1000
483 734
377 483
377 934
53 377
176 934
176 767
252 767
377 735
483 917
483 563
192 252
500 917
376 563
500 937
244 563
192 912
176 823
1 192
415 912
111 500
250 735
111 725
563 893
1 199
439 734
817 937
752 893
488 725
428 912
327 817
78 500
78 620
934 966
681 917
500 795
149 966
192 650
192 28...

output:

978624

result:

ok single line: '978624'

Test #221:

score: 21
Accepted
time: 3ms
memory: 3760kb

input:

1000
278 449
267 449
193 449
278 702
193 329
271 702
271 384
267 764
92 702
132 271
278 322
212 384
132 481
384 556
540 556
267 377
377 697
449 763
517 697
329 482
540 893
106 193
86 517
37 702
37 756
86 641
86 792
267 830
191 377
322 648
426 540
30 193
556 787
221 384
377 533
792 967
334 756
508 55...

output:

980907

result:

ok single line: '980907'

Test #222:

score: 21
Accepted
time: 5ms
memory: 3768kb

input:

1000
699 958
255 747
423 986
879 883
195 595
213 955
53 739
400 613
164 902
129 969
107 931
221 386
582 815
783 974
774 842
451 899
1 932
214 929
254 533
107 624
73 638
74 739
9 960
31 147
214 669
289 675
291 867
244 638
352 543
250 846
129 542
871 998
267 793
182 782
265 315
573 901
482 522
401 482...

output:

983819

result:

ok single line: '983819'

Test #223:

score: 21
Accepted
time: 5ms
memory: 4016kb

input:

999
4 606
471 679
109 662
37 337
428 467
55 507
153 749
290 582
507 546
85 186
173 669
110 277
465 469
216 796
711 877
70 943
69 415
72 150
33 62
222 570
148 776
455 569
304 982
451 625
275 531
371 737
441 479
290 715
258 356
967 981
61 848
191 837
205 251
805 896
757 797
131 262
323 623
760 861
60 ...

output:

981851

result:

ok single line: '981851'

Test #224:

score: 21
Accepted
time: 4ms
memory: 3784kb

input:

1000
224 950
197 1000
28 613
133 760
647 836
556 615
470 688
2 60
8 817
317 324
669 957
613 890
817 935
675 994
145 534
6 909
29 533
625 754
81 742
310 766
115 198
573 764
243 815
329 441
161 644
333 536
908 951
404 479
287 548
541 865
420 958
760 925
61 156
620 789
83 86
63 218
708 844
402 476
242 ...

output:

988389

result:

ok single line: '988389'

Test #225:

score: 21
Accepted
time: 4ms
memory: 3716kb

input:

999
267 668
388 633
175 743
98 622
125 660
409 839
235 936
316 617
862 901
732 878
409 817
59 760
574 947
374 620
88 838
97 901
243 946
73 160
95 803
50 109
198 303
479 635
163 737
266 821
124 529
919 957
176 289
264 388
148 906
454 713
719 843
291 434
151 254
951 952
835 849
146 931
686 967
469 571...

output:

986393

result:

ok single line: '986393'

Test #226:

score: 21
Accepted
time: 4ms
memory: 3748kb

input:

998
578 799
239 379
574 944
162 854
488 673
592 951
406 525
242 920
54 826
181 417
481 607
523 711
580 954
401 975
883 980
334 903
574 747
137 324
462 817
36 392
753 787
58 741
519 756
14 290
67 398
355 602
77 687
661 910
143 782
385 577
474 687
577 934
499 613
108 766
155 707
553 956
60 117
514 991...

output:

984399

result:

ok single line: '984399'

Test #227:

score: 21
Accepted
time: 3ms
memory: 3700kb

input:

1000
335 602
369 625
642 923
142 782
32 55
504 657
48 636
57 994
397 961
66 642
922 933
36 691
603 961
790 802
486 561
119 179
10 459
547 930
370 954
427 594
53 735
17 642
348 980
516 861
710 860
597 948
691 974
230 804
15 119
276 321
211 425
169 597
213 691
611 636
117 879
140 445
288 895
129 745
4...

output:

993345

result:

ok single line: '993345'

Test #228:

score: 21
Accepted
time: 3ms
memory: 3764kb

input:

1000
136 715
79 491
419 963
383 926
202 512
743 800
738 754
43 963
714 963
203 512
655 926
136 774
172 451
22 512
172 845
512 562
172 437
228 743
172 395
669 738
512 818
316 491
159 670
273 512
466 840
172 502
613 743
466 626
3 963
542 926
919 963
571 926
56 466
172 854
136 450
878 963
136 415
381 6...

output:

995304

result:

ok single line: '995304'

Test #229:

score: 21
Accepted
time: 0ms
memory: 3628kb

input:

4
1 2
1 3
1 4

output:

7

result:

ok single line: '7'

Test #230:

score: 21
Accepted
time: 0ms
memory: 3916kb

input:

1

output:

0

result:

ok single line: '0'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%