QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#809422#7216. Boxes on treeKellyWLJAC ✓3ms8204kbC++174.2kb2024-12-11 14:58:152024-12-11 14:58:32

Judging History

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

  • [2024-12-11 14:58:32]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:8204kb
  • [2024-12-11 14:58:15]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;

using pii = pair<int, int>;
const int N = 5010, SZ = (1 << 18) + 5;
static char buf[SZ], *bgn = buf, *til = buf;
char getc() {
    if(bgn == til)  bgn = buf, til = buf + fread(buf, 1, SZ, stdin);
    return bgn == til ? EOF : *bgn++;
}
template<typename T>
void read(T &x) {
    char ch = getc();  T fh = 0;   x = 0;
    while(ch < '0' || ch > '9')    fh |= (ch == '-'), ch = getc();
    while(ch >= '0' && ch <= '9')   x = x * 10 + ch - '0', ch = getc();
    x = fh ? -x : x;
}
template<typename Type, typename... argc>
void read(Type &x, argc &...args)   {read(x), read(args...);}
template<typename T>
void print(T x) {
    if(x < 0)  putchar('-'), x = -x;
    if(x / 10)  print(x / 10);
    putchar(x % 10 + '0');
}
int n, u, v, m, a[N], cnt, fr[N], id[N], del[N], vis[N], fa[N], ans, sum, nxt[N], val[N], dis[N], que[N], hh, tt, idx;
vector<int> edge[N], cir[N], has[N], in[N];
bool g[N][N];
void clear() {
    for(int i = 1; i <= cnt; ++i)   cir[i].clear(), has[i].clear(), in[i].clear();
    for(int i = 1; i <= n; ++i) fr[i] = vis[i] = 0, edge[i].clear();
    cnt = ans = sum = idx = m = 0;
}
struct edges {int u, v, w;}edg[N * N];
void dfs(int x, int fath) {
    fa[x] = fath;
    for(int y : edge[x])    if(y != fath)   dfs(y, x);
}
void bfs(int str) {
    hh = 1, tt = 0;
    memset(dis, 0x3f, sizeof(dis)); 
    for(int x : has[str])   que[++tt] = x, dis[x] = 0;
    while(hh <= tt) {
        int x = que[hh++];
        if(fr[x] != str && !g[str][fr[x]])  edg[++m] = {str, fr[x], dis[x]}, g[str][fr[x]] = true;
        for(int y : edge[x])    
            if(dis[y] > dis[x] + 1) dis[y] = dis[x] + 1, que[++tt] = y;
    }
}
void dmst() {
    int n = cnt, root = 1;
    while(1) {
        for(int i = 1; i <= n; ++i) nxt[i] = id[i] = del[i] = 0, val[i] = N;
        memset(vis, 0, sizeof(vis));
        idx = 0;
        for(int i = 1; i <= m; ++i)
            if(edg[i].w < val[edg[i].v])    val[edg[i].v] = edg[i].w, nxt[edg[i].v] = edg[i].u;
        nxt[root] = 0, val[root] = N;
        int ct = 0;
        for(int i = 1; i <= n; ++i) if(i != root)   sum += val[i];
        for(int i = 1; i <= n; ++i) if(!vis[i]) {
            int x = i;  ++ct;
            while(x && !vis[x]) vis[x] = ct, x = nxt[x];
            if(x && vis[x] == ct) {
                id[x] = ++idx;  int nw = nxt[x];    del[x] = val[x];
                while(nw != x)  id[nw] = idx, nw = nxt[nw];
            }
        }
        if(!idx)    return;
        for(int i = 1; i <= n; ++i) if(!id[i])  id[i] = ++idx;
        int nm = 0;
        for(int i = 1; i <= m; ++i) 
            if(id[edg[i].u] != id[edg[i].v])    edg[++nm] = {id[edg[i].u], id[edg[i].v], edg[i].w - val[edg[i].v]};
        n = idx, m = nm, root = id[root];
    }
}
void mian() {
    read(n), clear();
    for(int i = 1; i <= n; ++i) read(a[i]);
    for(int i = 1; i < n; ++i)  read(u, v), edge[u].pb(v), edge[v].pb(u);
    for(int i = 1; i <= n; ++i) if((i == 1 || i != a[i]) && !vis[i]) {
        ++cnt;  int x = i;
        while(a[x] != i)    cir[cnt].pb(x), x = a[x];
        cir[cnt].pb(x);
        for(int j : cir[cnt])   vis[j] = 1, fr[j] = cnt;
    }
    for(int i = 1; i <= cnt; ++i) {
        cir[i].pb(cir[i][0]);
        memset(vis, 0, sizeof(vis));
        for(int j = 0; j + 1 < cir[i].size(); ++j) {
            dfs(cir[i][j + 1], 0);
            for(int x = cir[i][j]; x; x = fa[x]) {
                ++ans;
                if(!vis[x]) vis[x] = 1, has[i].pb(x);
            }
            --ans;
        }
    }
    for(int i = 1; i <= cnt; ++i)   memset(g[i], 0, sizeof(g[i]));
    for(int i = 1; i <= cnt; ++i)   bfs(i);
    // cerr << cnt << "\n";
    dmst();
    // cerr << ans << " " << sum << "\n";
    print(ans + sum * 2), putchar('\n');
}
int main() {
    #ifdef Kelly
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #else
        // freopen("classic.in", "r", stdin);
        // freopen("classic.out", "w", stdout);
    #endif
    int T = 1; // read(T);
    while(T--)  mian();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7712kb

input:

3
1 3 2
1 2
2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4
2 1 4 3
1 3
3 2
3 4

output:

6

result:

ok 1 number(s): "6"

Test #3:

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

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

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

output:

8

result:

ok 1 number(s): "8"

Test #5:

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

input:

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

output:

10

result:

ok 1 number(s): "10"

Test #6:

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

input:

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

output:

20

result:

ok 1 number(s): "20"

Test #7:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #8:

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

input:

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

output:

18

result:

ok 1 number(s): "18"

Test #9:

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

input:

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

output:

30

result:

ok 1 number(s): "30"

Test #10:

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

input:

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

output:

32

result:

ok 1 number(s): "32"

Test #11:

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

input:

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

output:

28

result:

ok 1 number(s): "28"

Test #12:

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

input:

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

output:

20

result:

ok 1 number(s): "20"

Test #13:

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

input:

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

output:

32

result:

ok 1 number(s): "32"

Test #14:

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

input:

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

output:

34

result:

ok 1 number(s): "34"

Test #15:

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

input:

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

output:

44

result:

ok 1 number(s): "44"

Test #16:

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

input:

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

output:

26

result:

ok 1 number(s): "26"

Test #17:

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

input:

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

output:

36

result:

ok 1 number(s): "36"

Test #18:

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

input:

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

output:

30

result:

ok 1 number(s): "30"

Test #19:

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

input:

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

output:

76

result:

ok 1 number(s): "76"

Test #20:

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

input:

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

output:

82

result:

ok 1 number(s): "82"

Test #21:

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

input:

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

output:

92

result:

ok 1 number(s): "92"

Test #22:

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

input:

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

output:

114

result:

ok 1 number(s): "114"

Test #23:

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

input:

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

output:

106

result:

ok 1 number(s): "106"

Test #24:

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

input:

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

output:

174

result:

ok 1 number(s): "174"

Test #25:

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

input:

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

output:

180

result:

ok 1 number(s): "180"

Test #26:

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

input:

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

output:

134

result:

ok 1 number(s): "134"

Test #27:

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

input:

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

output:

120

result:

ok 1 number(s): "120"

Test #28:

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

input:

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

output:

154

result:

ok 1 number(s): "154"

Test #29:

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

input:

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

output:

148

result:

ok 1 number(s): "148"

Test #30:

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

input:

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

output:

130

result:

ok 1 number(s): "130"

Test #31:

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

input:

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

output:

120

result:

ok 1 number(s): "120"

Test #32:

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

input:

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

output:

214

result:

ok 1 number(s): "214"

Test #33:

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

input:

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

output:

160

result:

ok 1 number(s): "160"

Test #34:

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

input:

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

output:

294

result:

ok 1 number(s): "294"

Test #35:

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

input:

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

output:

362

result:

ok 1 number(s): "362"

Test #36:

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

input:

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

output:

380

result:

ok 1 number(s): "380"

Test #37:

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

input:

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

output:

330

result:

ok 1 number(s): "330"

Test #38:

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

input:

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

output:

464

result:

ok 1 number(s): "464"

Test #39:

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

input:

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

output:

462

result:

ok 1 number(s): "462"

Test #40:

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

input:

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

output:

592

result:

ok 1 number(s): "592"

Test #41:

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

input:

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

output:

486

result:

ok 1 number(s): "486"

Test #42:

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

input:

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

output:

364

result:

ok 1 number(s): "364"

Test #43:

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

input:

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

output:

362

result:

ok 1 number(s): "362"

Test #44:

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

input:

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

output:

1070

result:

ok 1 number(s): "1070"

Test #45:

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

input:

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

output:

1088

result:

ok 1 number(s): "1088"

Test #46:

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

input:

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

output:

1008

result:

ok 1 number(s): "1008"

Test #47:

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

input:

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

output:

894

result:

ok 1 number(s): "894"

Test #48:

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

input:

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

output:

870

result:

ok 1 number(s): "870"

Test #49:

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

input:

500
478 2 3 202 93 321 7 8 9 10 11 12 13 14 15 16 108 445 19 20 21 22 297 380 25 236 27 28 455 30 31 32 33 130 35 36 37 38 121 26 41 42 43 44 45 46 47 48 49 167 205 52 53 54 55 74 126 58 59 154 61 62 63 64 393 486 67 68 69 70 161 72 73 96 360 76 77 78 79 80 81 82 83 280 85 86 87 88 89 90 480 206 5 9...

output:

3420

result:

ok 1 number(s): "3420"

Test #50:

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

input:

500
1 2 378 4 5 6 7 8 9 135 11 12 13 467 15 294 371 18 19 203 21 327 342 24 25 175 27 227 253 30 31 32 236 34 35 36 37 273 39 355 41 306 43 247 45 219 47 48 49 153 102 52 95 54 55 343 57 58 59 386 105 78 297 64 65 56 220 68 69 70 71 72 73 74 75 76 77 62 79 80 81 82 418 187 457 434 87 88 89 267 91 15...

output:

3294

result:

ok 1 number(s): "3294"

Test #51:

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

input:

500
88 2 22 312 5 460 77 114 135 10 440 12 13 443 15 16 39 351 19 20 21 3 1 24 25 26 27 28 37 30 31 32 343 323 211 90 175 38 261 365 338 496 43 44 463 124 47 72 293 355 386 52 470 274 437 403 57 58 316 60 61 62 63 64 65 66 67 68 246 70 162 369 73 74 231 76 321 53 79 80 252 156 83 263 428 86 438 217 ...

output:

3404

result:

ok 1 number(s): "3404"

Test #52:

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

input:

500
1 2 286 4 20 6 7 8 9 10 11 351 13 14 15 16 17 18 19 312 21 22 23 120 25 498 27 28 29 188 83 32 129 147 454 270 163 81 39 40 41 383 194 44 45 46 47 48 49 50 51 52 53 54 55 56 57 62 59 211 61 349 63 459 65 66 374 33 472 70 71 72 73 74 75 76 237 78 313 80 137 204 353 84 85 86 87 88 127 249 463 92 9...

output:

3852

result:

ok 1 number(s): "3852"

Test #53:

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

input:

500
1 287 3 427 5 377 7 8 113 10 150 496 13 14 318 461 17 410 19 20 270 222 23 68 25 26 27 28 29 33 485 172 188 34 35 36 37 38 39 40 41 454 43 44 45 46 47 48 49 50 51 206 53 213 55 430 378 58 351 60 61 62 499 64 65 66 67 285 392 59 71 72 73 417 257 76 77 409 303 80 81 82 149 84 85 86 87 352 89 90 91...

output:

4326

result:

ok 1 number(s): "4326"

Test #54:

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

input:

500
247 47 3 176 5 6 7 8 9 10 11 12 13 14 15 278 17 453 19 20 244 22 23 24 25 26 27 28 29 30 31 32 351 193 35 33 326 394 39 169 195 42 43 44 45 182 360 48 260 129 51 52 53 54 224 217 34 58 59 60 37 62 21 469 65 66 67 68 69 70 71 72 73 74 121 76 77 86 79 463 50 82 83 84 281 419 87 88 89 90 259 92 93 ...

output:

4312

result:

ok 1 number(s): "4312"

Test #55:

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

input:

500
112 26 184 4 62 6 7 8 9 10 116 329 13 14 15 16 17 18 19 20 21 22 23 24 25 99 27 111 29 30 31 32 394 34 35 72 37 38 39 43 41 280 450 44 45 140 151 48 97 50 51 353 53 337 55 56 154 58 59 40 243 220 444 133 65 147 326 68 308 70 71 74 73 489 75 76 77 78 66 80 81 82 289 84 292 451 87 88 473 33 126 92...

output:

3966

result:

ok 1 number(s): "3966"

Test #56:

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

input:

500
440 442 3 359 49 17 393 8 9 10 451 12 13 14 15 386 20 141 19 486 381 22 23 46 25 2 27 28 104 397 31 165 33 378 35 36 37 38 39 371 41 42 43 44 223 87 48 496 437 487 304 52 372 54 412 282 57 227 177 60 61 224 63 64 147 66 149 40 69 70 71 72 73 485 75 76 77 78 361 80 137 82 83 414 85 86 197 88 89 9...

output:

3932

result:

ok 1 number(s): "3932"

Test #57:

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

input:

500
1 2 206 4 58 6 49 177 170 10 11 447 13 62 15 16 17 18 56 497 21 22 300 361 25 262 27 28 168 30 31 32 33 34 395 450 37 38 39 211 41 42 43 44 45 46 333 48 144 50 145 5 427 54 40 263 57 52 59 60 61 184 63 64 65 350 67 68 221 70 71 72 479 74 75 76 77 78 415 80 420 82 500 84 85 173 87 88 89 90 91 282...

output:

3912

result:

ok 1 number(s): "3912"

Test #58:

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

input:

500
1 2 3 102 303 6 262 36 9 206 77 12 13 383 15 436 451 18 331 20 194 22 23 24 25 26 27 395 29 313 31 32 33 114 35 127 58 45 39 40 41 42 30 38 218 139 47 48 49 19 134 52 466 291 8 202 57 61 258 60 97 270 63 199 122 149 67 224 69 70 238 72 73 290 75 76 169 78 390 4 81 62 391 499 85 86 228 153 361 23...

output:

5334

result:

ok 1 number(s): "5334"

Test #59:

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

input:

500
340 2 127 18 153 6 7 8 9 10 90 12 13 14 15 16 17 61 19 470 21 22 28 24 25 188 27 473 29 30 158 32 344 34 140 36 96 38 39 40 108 453 43 44 45 46 47 48 49 50 113 283 53 1 439 279 343 58 196 60 121 100 26 362 75 66 483 68 69 20 71 133 73 74 72 76 276 65 79 324 429 82 83 84 85 86 87 88 31 227 91 92 ...

output:

4454

result:

ok 1 number(s): "4454"

Test #60:

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

input:

500
1 2 306 4 5 13 396 8 148 424 317 12 490 201 15 16 95 18 19 326 476 307 181 24 25 416 257 224 29 237 442 32 319 348 159 378 432 97 39 40 35 42 11 343 45 324 47 48 341 204 51 52 352 54 55 56 171 414 59 115 61 62 10 64 65 66 67 250 435 70 71 192 162 74 3 388 77 454 79 80 81 82 408 84 31 20 245 88 3...

output:

4892

result:

ok 1 number(s): "4892"

Test #61:

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

input:

500
1 2 3 470 5 488 49 8 9 10 11 12 356 32 15 16 111 205 19 20 21 22 6 24 25 26 27 432 134 30 127 275 33 34 35 36 37 38 61 40 41 17 408 330 449 46 491 48 42 50 51 52 53 54 459 56 57 14 59 60 145 62 63 64 65 66 409 68 69 157 71 72 73 74 278 305 77 78 79 80 81 393 120 106 85 86 87 88 469 90 435 92 93 ...

output:

4026

result:

ok 1 number(s): "4026"

Test #62:

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

input:

500
38 2 3 213 5 6 7 8 271 10 11 237 13 14 15 16 17 18 19 215 21 22 23 24 467 338 27 28 29 30 31 216 33 188 35 321 37 398 32 175 452 42 43 44 45 46 47 20 49 50 51 52 53 54 374 119 57 192 59 60 70 62 63 64 65 66 261 68 431 236 71 72 73 74 104 61 392 77 79 80 127 82 83 92 85 198 308 86 89 26 91 483 93...

output:

3648

result:

ok 1 number(s): "3648"

Test #63:

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

input:

500
1 2 3 4 219 6 130 8 9 387 241 334 67 111 15 16 17 18 19 330 21 22 23 24 25 191 456 28 29 81 31 381 33 34 118 177 37 213 416 342 41 409 43 325 45 46 124 308 49 50 51 316 53 54 55 56 57 30 47 60 61 71 131 64 65 66 468 417 103 70 74 249 14 42 352 76 364 78 79 80 151 82 83 84 85 194 159 88 89 90 91 ...

output:

4390

result:

ok 1 number(s): "4390"

Test #64:

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

input:

500
231 241 368 185 312 218 267 284 131 88 307 280 123 173 147 493 236 303 390 476 94 177 187 487 74 465 17 130 256 272 386 316 491 370 25 321 395 416 427 409 324 406 299 337 89 348 142 269 309 227 203 381 156 38 294 252 291 500 338 4 175 254 249 98 323 268 199 328 138 412 55 155 205 62 102 282 129 ...

output:

8928

result:

ok 1 number(s): "8928"

Test #65:

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

input:

500
374 124 369 20 187 435 89 406 414 195 296 276 144 338 23 205 214 333 151 160 376 309 306 431 191 149 433 391 95 268 247 325 65 269 253 393 240 486 155 9 349 430 442 390 126 154 360 147 94 342 443 208 67 168 461 457 381 404 189 186 487 281 303 327 319 274 320 161 70 118 152 497 490 13 415 170 357...

output:

8534

result:

ok 1 number(s): "8534"

Test #66:

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

input:

500
119 60 37 45 381 240 432 313 90 475 299 366 48 184 238 403 62 382 19 55 376 283 115 375 248 150 447 244 49 22 405 26 296 43 449 168 327 456 222 406 125 346 181 335 470 165 131 103 275 446 201 132 325 268 29 40 151 286 256 281 339 217 5 233 102 185 92 177 338 81 129 136 328 211 412 36 340 6 11 39...

output:

8254

result:

ok 1 number(s): "8254"

Test #67:

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

input:

500
174 88 444 392 224 266 57 379 421 282 244 141 284 101 366 167 42 256 294 275 133 100 318 234 86 144 188 248 317 52 307 270 215 351 401 150 90 85 235 61 173 398 16 349 384 323 454 5 449 12 445 199 51 321 83 204 119 353 36 179 98 211 66 129 415 162 288 142 28 362 469 74 107 146 369 299 72 311 320 ...

output:

9498

result:

ok 1 number(s): "9498"

Test #68:

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

input:

500
20 75 49 139 488 279 151 348 302 328 193 154 214 265 158 192 10 18 294 28 222 128 425 498 456 392 217 368 169 308 92 473 282 390 84 319 289 213 178 144 270 387 354 271 24 190 87 416 206 34 458 370 44 165 471 423 367 76 120 138 74 397 443 224 439 48 73 386 42 63 395 337 307 174 207 426 445 231 49...

output:

12516

result:

ok 1 number(s): "12516"

Extra Test:

score: 0
Extra Test Passed