Submission #282337

# Submission time Handle Problem Language Result Execution time Memory
282337 2020-08-24T10:20:36 Z imeimi2000 Mountains and Valleys (CCO20_day1problem3) C++17
25 / 25
3118 ms 214096 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long llong;
typedef pair<int, int> pii;

int n, m;
int X[2000001], Y[2000001], W[2000001];
vector<int> edge[500001];

namespace TSP {
    llong dp[1 << 20][20];
    llong dist[20][20];
    llong solve() {
        memset(dist, 0x3f, sizeof(dist));
        for (int i = 1; i <= m; ++i) {
            int x, y, w;
            cin >> x >> y >> w;
            dist[x][y] = dist[y][x] = min(dist[x][y], 1ll * w);
        }
        for (int i = 0; i < n; ++i) dist[i][i] = 0;
        for (int k = 0; k < n; ++k) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        memset(dp, 0x3f, sizeof(dp));
        for (int i = 0; i < n; ++i) dp[1 << i][i] = 0;
        for (int i = 0; i < (1 << n); ++i) {
            for (int j = 0; j < n; ++j) {
                if ((i >> j) & 1) for (int k = 0; k < n; ++k) {
                    if ((i >> k) & 1) continue;
                    dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + dist[j][k]);
                }
            }
        }
        return *min_element(dp[(1 << n) - 1], dp[(1 << n) - 1] + n);
    }
}

template <int T>
struct save_max {
    int val[T], idx[T];
    void init(int v = 0) {
        memset(val, v, sizeof(val));
        memset(idx, 0, sizeof(idx));
    }
    void save(int v, int i) {
        for (int j = 0; j < T; ++j) {
            if (val[j] >= v) continue;
            for (int k = T - 1; k > j; --k) {
                val[k] = val[k - 1];
                idx[k] = idx[k - 1];
            }
            val[j] = v;
            idx[j] = i;
            break;
        }
    }
    void add(int x) {
        for (int i = 0; i < T; ++i) val[i] += x;
    }
    int get(int idx1 = -1, int idx2 = -1) const {
        for (int i = 0; i < T; ++i) {
            if (idx[i] == idx1 || idx[i] == idx2) continue;
            return val[i];
        }
        printf("get(%d, %d), idx[0] = %d\n", idx1, idx2, idx[0]);
        exit(1);
    }
    int get2(int idx1 = -1, int idx2 = -1) {
        int cnt = 2, sum = 0;
        for (int i = 0; i < T && cnt; ++i) {
            if (idx[i] == idx1 || idx[i] == idx2) continue;
            --cnt, sum += val[i];
        }
        if (cnt) printf("get(%d, %d), idx[0] = %d", idx1, idx2, idx[0]), exit(2);
        return sum;
    }
};

bool del[500001];
save_max<4> dis_down[500001];
save_max<3> dis_maxd[500001];

void dfs2(int x, int p) {
    for (int i : edge[x]) {
        if (i == p) continue;
        if (!del[i]) dfs2(i, x);
        dis_down[x].save(dis_down[i].get(x) + 1, i);
        dis_maxd[x].save(max(dis_down[i].get2(x), dis_maxd[i].get(x)), i);
    }
}

save_max<1> dis_toup[500001];
save_max<1> dis_maxu[500001];
save_max<1> dis_root[500001];
int subtree[500001], dep[500001];

int disu[500001], dism[500001], disd[500001];
void dfs3(int x, int p) {
    dep[x] = dep[p] + 1;
    for (int i : edge[x]) {
        if (i == p || del[i]) continue;
        dis_toup[i].save(dis_toup[x].get() - 1, x);
        dis_toup[i].save(dis_down[x].get(i) - 1, x);
        dis_maxu[i].save(dis_maxu[x].get(), x);
        dis_maxu[i].save(dis_down[x].get2(i), x);
        dis_maxu[i].save(dis_down[x].get(i) + dis_toup[x].get(), x);
        dis_root[i].save(dis_root[x].get(), x);
        dis_root[i].save(dis_down[x].get(i) - dep[x], x);
        subtree[i] = subtree[x];
        disu[i] = max(disu[x], dep[x] + dis_down[x].get(i));
        dism[i] = max(dism[x], disu[p] - dep[x] + dis_down[x].get(i));
        disd[i] = max(disd[x], dis_down[x].get(i)) + 1;
        dfs3(i, x);
    }
    dis_root[x].save(dis_down[x].get() - dep[x], x);
    dism[x] = max(dism[x], disu[x] - dep[x] + dis_down[x].get());
    disd[x] = max(disd[x], dis_down[x].get()) - dep[x];
}


vector<int> qs[500001];
int ans;
void solve(int x) {
    dfs2(x, 0);
    subtree[x] = -1;
    dep[x] = 0;
    for (int i : edge[x]) {
        if (del[i]) continue;
        subtree[i] = i;
        disu[i] = 0;
        dism[i] = -1e8;
        disd[i] = 0;
        dfs3(i, x);
    }
    for (int i : qs[x]) {
        int a = X[i], b = Y[i];
        int sa = subtree[a], sb = subtree[b];
        if (sa == sb) continue;
        int d = max(dis_down[x].get2(sa, sb), dis_maxd[x].get(sa, sb));
        int d1 = dis_down[x].get(sa, sb);
        int d2 = a != x ? dis_root[a].get() : 0;
        int d3 = b != x ? dis_root[b].get() : 0;
        d = max({ d, d1 + d2, d2 + d3, d3 + d1 });
        for (int j : { a, b }) if (j != x) {
            d = max({ d, dis_maxd[j].get(), dis_down[j].get2(), dis_maxu[j].get(), dis_down[j].get() + dis_toup[j].get() });
            d = max(d, 2 + max(dism[j], dis_down[x].get(sa, sb) + max(dism[j], dis_down[j].get() - dep[j])));
        }
        ans = min(ans, 2 * n - 2 - dep[a] - dep[b] - d + W[i]);
    }
}

int sz[500001];
void dfs1(int x, int p) {
    dis_down[x].init();
    dis_maxd[x].init();
    dis_toup[x].init();
    dis_maxu[x].init();
    dis_root[x].init();
    sz[x] = 1;
    for (int i : edge[x]) {
        if (i == p || del[i]) continue;
        dfs1(i, x);
        sz[x] += sz[i];
    }
}

void centroid(int x) {
    vector<int> &idx = qs[x];
    if (idx.empty()) return;
    dfs1(x, 0);
    {
        int p = 0, s = sz[x];
        for (bool loop = 0; !loop; loop ^= 1) {
            for (int i : edge[x]) {
                if (i == p || del[i]) continue;
                if (sz[i] * 2 > s) {
                    p = x;
                    x = i;
                    loop = 1;
                    break;
                }
            }
        }
    }
    swap(idx, qs[x]);
    solve(x);
    del[x] = 1;
    for (int i : qs[x]) {
        if (subtree[X[i]] == subtree[Y[i]]) qs[subtree[X[i]]].push_back(i);
    }
    qs[x].clear();
    qs[x].shrink_to_fit();
    for (int i : edge[x]) {
        if (del[i]) continue;
        centroid(i);
    }
}

int main() {
#ifdef imeimi
    //freopen("oi/cco20/3.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
#ifndef imeimi
    if (n <= 20) return printf("%lld\n", TSP::solve()), 0;
#endif
    for (int i = 1; i <= m; ++i) {
        cin >> X[i] >> Y[i] >> W[i];
        ++X[i], ++Y[i];
        if (W[i] > 1) {
            qs[1].push_back(i);
            continue;
        }
        edge[X[i]].push_back(Y[i]);
        edge[Y[i]].push_back(X[i]);
    }
    dfs2(1, 0);
    ans = 2 * n - 2 - max(dis_maxd[1].get(), dis_down[1].get2());
    centroid(1);
    printf("%d\n", ans);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 25344 KB Output is correct
2 Correct 22 ms 25344 KB Output is correct
3 Correct 22 ms 25216 KB Output is correct
4 Correct 24 ms 25088 KB Output is correct
5 Correct 24 ms 25088 KB Output is correct
6 Correct 23 ms 24960 KB Output is correct
7 Correct 22 ms 25344 KB Output is correct
8 Correct 22 ms 25216 KB Output is correct
9 Correct 23 ms 25344 KB Output is correct
10 Correct 22 ms 25088 KB Output is correct
11 Correct 26 ms 25208 KB Output is correct
12 Correct 21 ms 24960 KB Output is correct
13 Correct 26 ms 25272 KB Output is correct
14 Correct 29 ms 25216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
36 Correct 15 ms 23936 KB Output is correct
37 Correct 19 ms 23936 KB Output is correct
38 Correct 17 ms 23936 KB Output is correct
39 Correct 17 ms 23936 KB Output is correct
40 Correct 16 ms 23920 KB Output is correct
41 Correct 16 ms 23936 KB Output is correct
42 Correct 16 ms 23936 KB Output is correct
43 Correct 17 ms 23928 KB Output is correct
44 Correct 17 ms 23936 KB Output is correct
45 Correct 17 ms 23936 KB Output is correct
46 Correct 16 ms 23936 KB Output is correct
47 Correct 19 ms 23928 KB Output is correct
48 Correct 17 ms 23936 KB Output is correct
49 Correct 17 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
36 Correct 15 ms 23936 KB Output is correct
37 Correct 19 ms 23936 KB Output is correct
38 Correct 17 ms 23936 KB Output is correct
39 Correct 17 ms 23936 KB Output is correct
40 Correct 16 ms 23920 KB Output is correct
41 Correct 16 ms 23936 KB Output is correct
42 Correct 16 ms 23936 KB Output is correct
43 Correct 17 ms 23928 KB Output is correct
44 Correct 17 ms 23936 KB Output is correct
45 Correct 17 ms 23936 KB Output is correct
46 Correct 16 ms 23936 KB Output is correct
47 Correct 19 ms 23928 KB Output is correct
48 Correct 17 ms 23936 KB Output is correct
49 Correct 17 ms 23936 KB Output is correct
50 Correct 19 ms 24064 KB Output is correct
51 Correct 16 ms 24056 KB Output is correct
52 Correct 17 ms 24064 KB Output is correct
53 Correct 17 ms 24064 KB Output is correct
54 Correct 17 ms 24064 KB Output is correct
55 Correct 16 ms 24076 KB Output is correct
56 Correct 17 ms 24064 KB Output is correct
57 Correct 17 ms 24064 KB Output is correct
58 Correct 17 ms 24064 KB Output is correct
59 Correct 17 ms 24064 KB Output is correct
60 Correct 17 ms 24064 KB Output is correct
61 Correct 17 ms 24064 KB Output is correct
62 Correct 17 ms 24064 KB Output is correct
63 Correct 20 ms 24064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
36 Correct 21 ms 25344 KB Output is correct
37 Correct 22 ms 25344 KB Output is correct
38 Correct 22 ms 25216 KB Output is correct
39 Correct 24 ms 25088 KB Output is correct
40 Correct 24 ms 25088 KB Output is correct
41 Correct 23 ms 24960 KB Output is correct
42 Correct 22 ms 25344 KB Output is correct
43 Correct 22 ms 25216 KB Output is correct
44 Correct 23 ms 25344 KB Output is correct
45 Correct 22 ms 25088 KB Output is correct
46 Correct 26 ms 25208 KB Output is correct
47 Correct 21 ms 24960 KB Output is correct
48 Correct 26 ms 25272 KB Output is correct
49 Correct 29 ms 25216 KB Output is correct
50 Correct 15 ms 23936 KB Output is correct
51 Correct 19 ms 23936 KB Output is correct
52 Correct 17 ms 23936 KB Output is correct
53 Correct 17 ms 23936 KB Output is correct
54 Correct 16 ms 23920 KB Output is correct
55 Correct 16 ms 23936 KB Output is correct
56 Correct 16 ms 23936 KB Output is correct
57 Correct 17 ms 23928 KB Output is correct
58 Correct 17 ms 23936 KB Output is correct
59 Correct 17 ms 23936 KB Output is correct
60 Correct 16 ms 23936 KB Output is correct
61 Correct 19 ms 23928 KB Output is correct
62 Correct 17 ms 23936 KB Output is correct
63 Correct 17 ms 23936 KB Output is correct
64 Correct 19 ms 24064 KB Output is correct
65 Correct 16 ms 24056 KB Output is correct
66 Correct 17 ms 24064 KB Output is correct
67 Correct 17 ms 24064 KB Output is correct
68 Correct 17 ms 24064 KB Output is correct
69 Correct 16 ms 24076 KB Output is correct
70 Correct 17 ms 24064 KB Output is correct
71 Correct 17 ms 24064 KB Output is correct
72 Correct 17 ms 24064 KB Output is correct
73 Correct 17 ms 24064 KB Output is correct
74 Correct 17 ms 24064 KB Output is correct
75 Correct 17 ms 24064 KB Output is correct
76 Correct 17 ms 24064 KB Output is correct
77 Correct 20 ms 24064 KB Output is correct
78 Correct 24 ms 25120 KB Output is correct
79 Correct 22 ms 25192 KB Output is correct
80 Correct 21 ms 25088 KB Output is correct
81 Correct 22 ms 25216 KB Output is correct
82 Correct 24 ms 25088 KB Output is correct
83 Correct 23 ms 24960 KB Output is correct
84 Correct 22 ms 25216 KB Output is correct
85 Correct 22 ms 25216 KB Output is correct
86 Correct 23 ms 25344 KB Output is correct
87 Correct 21 ms 25088 KB Output is correct
88 Correct 23 ms 25088 KB Output is correct
89 Correct 21 ms 25088 KB Output is correct
90 Correct 20 ms 24960 KB Output is correct
91 Correct 22 ms 24960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
36 Correct 21 ms 25344 KB Output is correct
37 Correct 22 ms 25344 KB Output is correct
38 Correct 22 ms 25216 KB Output is correct
39 Correct 24 ms 25088 KB Output is correct
40 Correct 24 ms 25088 KB Output is correct
41 Correct 23 ms 24960 KB Output is correct
42 Correct 22 ms 25344 KB Output is correct
43 Correct 22 ms 25216 KB Output is correct
44 Correct 23 ms 25344 KB Output is correct
45 Correct 22 ms 25088 KB Output is correct
46 Correct 26 ms 25208 KB Output is correct
47 Correct 21 ms 24960 KB Output is correct
48 Correct 26 ms 25272 KB Output is correct
49 Correct 29 ms 25216 KB Output is correct
50 Correct 15 ms 23936 KB Output is correct
51 Correct 19 ms 23936 KB Output is correct
52 Correct 17 ms 23936 KB Output is correct
53 Correct 17 ms 23936 KB Output is correct
54 Correct 16 ms 23920 KB Output is correct
55 Correct 16 ms 23936 KB Output is correct
56 Correct 16 ms 23936 KB Output is correct
57 Correct 17 ms 23928 KB Output is correct
58 Correct 17 ms 23936 KB Output is correct
59 Correct 17 ms 23936 KB Output is correct
60 Correct 16 ms 23936 KB Output is correct
61 Correct 19 ms 23928 KB Output is correct
62 Correct 17 ms 23936 KB Output is correct
63 Correct 17 ms 23936 KB Output is correct
64 Correct 19 ms 24064 KB Output is correct
65 Correct 16 ms 24056 KB Output is correct
66 Correct 17 ms 24064 KB Output is correct
67 Correct 17 ms 24064 KB Output is correct
68 Correct 17 ms 24064 KB Output is correct
69 Correct 16 ms 24076 KB Output is correct
70 Correct 17 ms 24064 KB Output is correct
71 Correct 17 ms 24064 KB Output is correct
72 Correct 17 ms 24064 KB Output is correct
73 Correct 17 ms 24064 KB Output is correct
74 Correct 17 ms 24064 KB Output is correct
75 Correct 17 ms 24064 KB Output is correct
76 Correct 17 ms 24064 KB Output is correct
77 Correct 20 ms 24064 KB Output is correct
78 Correct 24 ms 25120 KB Output is correct
79 Correct 22 ms 25192 KB Output is correct
80 Correct 21 ms 25088 KB Output is correct
81 Correct 22 ms 25216 KB Output is correct
82 Correct 24 ms 25088 KB Output is correct
83 Correct 23 ms 24960 KB Output is correct
84 Correct 22 ms 25216 KB Output is correct
85 Correct 22 ms 25216 KB Output is correct
86 Correct 23 ms 25344 KB Output is correct
87 Correct 21 ms 25088 KB Output is correct
88 Correct 23 ms 25088 KB Output is correct
89 Correct 21 ms 25088 KB Output is correct
90 Correct 20 ms 24960 KB Output is correct
91 Correct 22 ms 24960 KB Output is correct
92 Correct 241 ms 43120 KB Output is correct
93 Correct 234 ms 42864 KB Output is correct
94 Correct 188 ms 41708 KB Output is correct
95 Correct 163 ms 41336 KB Output is correct
96 Correct 202 ms 41464 KB Output is correct
97 Correct 296 ms 46064 KB Output is correct
98 Correct 214 ms 46704 KB Output is correct
99 Correct 217 ms 42608 KB Output is correct
100 Correct 207 ms 43280 KB Output is correct
101 Correct 230 ms 42736 KB Output is correct
102 Correct 132 ms 39640 KB Output is correct
103 Correct 205 ms 45420 KB Output is correct
104 Correct 204 ms 43380 KB Output is correct
105 Correct 278 ms 44144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 188152 KB Output is correct
2 Correct 107 ms 188024 KB Output is correct
3 Correct 106 ms 188024 KB Output is correct
4 Correct 109 ms 188040 KB Output is correct
5 Correct 105 ms 188024 KB Output is correct
6 Correct 108 ms 188024 KB Output is correct
7 Correct 106 ms 188024 KB Output is correct
8 Correct 107 ms 188152 KB Output is correct
9 Correct 108 ms 188024 KB Output is correct
10 Correct 107 ms 188024 KB Output is correct
11 Correct 107 ms 188024 KB Output is correct
12 Correct 105 ms 188152 KB Output is correct
13 Correct 106 ms 188024 KB Output is correct
14 Correct 107 ms 188024 KB Output is correct
15 Correct 106 ms 188024 KB Output is correct
16 Correct 108 ms 188024 KB Output is correct
17 Correct 108 ms 188024 KB Output is correct
18 Correct 110 ms 188064 KB Output is correct
19 Correct 125 ms 188024 KB Output is correct
20 Correct 121 ms 188024 KB Output is correct
21 Correct 120 ms 188108 KB Output is correct
22 Correct 780 ms 188152 KB Output is correct
23 Correct 414 ms 188024 KB Output is correct
24 Correct 413 ms 188024 KB Output is correct
25 Correct 270 ms 188024 KB Output is correct
26 Correct 253 ms 188152 KB Output is correct
27 Correct 779 ms 188056 KB Output is correct
28 Correct 262 ms 188024 KB Output is correct
29 Correct 253 ms 188024 KB Output is correct
30 Correct 252 ms 188128 KB Output is correct
31 Correct 274 ms 188024 KB Output is correct
32 Correct 119 ms 188024 KB Output is correct
33 Correct 115 ms 188016 KB Output is correct
34 Correct 248 ms 188024 KB Output is correct
35 Correct 243 ms 188176 KB Output is correct
36 Correct 21 ms 25344 KB Output is correct
37 Correct 22 ms 25344 KB Output is correct
38 Correct 22 ms 25216 KB Output is correct
39 Correct 24 ms 25088 KB Output is correct
40 Correct 24 ms 25088 KB Output is correct
41 Correct 23 ms 24960 KB Output is correct
42 Correct 22 ms 25344 KB Output is correct
43 Correct 22 ms 25216 KB Output is correct
44 Correct 23 ms 25344 KB Output is correct
45 Correct 22 ms 25088 KB Output is correct
46 Correct 26 ms 25208 KB Output is correct
47 Correct 21 ms 24960 KB Output is correct
48 Correct 26 ms 25272 KB Output is correct
49 Correct 29 ms 25216 KB Output is correct
50 Correct 15 ms 23936 KB Output is correct
51 Correct 19 ms 23936 KB Output is correct
52 Correct 17 ms 23936 KB Output is correct
53 Correct 17 ms 23936 KB Output is correct
54 Correct 16 ms 23920 KB Output is correct
55 Correct 16 ms 23936 KB Output is correct
56 Correct 16 ms 23936 KB Output is correct
57 Correct 17 ms 23928 KB Output is correct
58 Correct 17 ms 23936 KB Output is correct
59 Correct 17 ms 23936 KB Output is correct
60 Correct 16 ms 23936 KB Output is correct
61 Correct 19 ms 23928 KB Output is correct
62 Correct 17 ms 23936 KB Output is correct
63 Correct 17 ms 23936 KB Output is correct
64 Correct 19 ms 24064 KB Output is correct
65 Correct 16 ms 24056 KB Output is correct
66 Correct 17 ms 24064 KB Output is correct
67 Correct 17 ms 24064 KB Output is correct
68 Correct 17 ms 24064 KB Output is correct
69 Correct 16 ms 24076 KB Output is correct
70 Correct 17 ms 24064 KB Output is correct
71 Correct 17 ms 24064 KB Output is correct
72 Correct 17 ms 24064 KB Output is correct
73 Correct 17 ms 24064 KB Output is correct
74 Correct 17 ms 24064 KB Output is correct
75 Correct 17 ms 24064 KB Output is correct
76 Correct 17 ms 24064 KB Output is correct
77 Correct 20 ms 24064 KB Output is correct
78 Correct 24 ms 25120 KB Output is correct
79 Correct 22 ms 25192 KB Output is correct
80 Correct 21 ms 25088 KB Output is correct
81 Correct 22 ms 25216 KB Output is correct
82 Correct 24 ms 25088 KB Output is correct
83 Correct 23 ms 24960 KB Output is correct
84 Correct 22 ms 25216 KB Output is correct
85 Correct 22 ms 25216 KB Output is correct
86 Correct 23 ms 25344 KB Output is correct
87 Correct 21 ms 25088 KB Output is correct
88 Correct 23 ms 25088 KB Output is correct
89 Correct 21 ms 25088 KB Output is correct
90 Correct 20 ms 24960 KB Output is correct
91 Correct 22 ms 24960 KB Output is correct
92 Correct 241 ms 43120 KB Output is correct
93 Correct 234 ms 42864 KB Output is correct
94 Correct 188 ms 41708 KB Output is correct
95 Correct 163 ms 41336 KB Output is correct
96 Correct 202 ms 41464 KB Output is correct
97 Correct 296 ms 46064 KB Output is correct
98 Correct 214 ms 46704 KB Output is correct
99 Correct 217 ms 42608 KB Output is correct
100 Correct 207 ms 43280 KB Output is correct
101 Correct 230 ms 42736 KB Output is correct
102 Correct 132 ms 39640 KB Output is correct
103 Correct 205 ms 45420 KB Output is correct
104 Correct 204 ms 43380 KB Output is correct
105 Correct 278 ms 44144 KB Output is correct
106 Correct 3113 ms 214096 KB Output is correct
107 Correct 3087 ms 211392 KB Output is correct
108 Correct 2322 ms 178444 KB Output is correct
109 Correct 2345 ms 177240 KB Output is correct
110 Correct 2345 ms 177824 KB Output is correct
111 Correct 1597 ms 159732 KB Output is correct
112 Correct 3118 ms 209740 KB Output is correct
113 Correct 2332 ms 188720 KB Output is correct
114 Correct 3055 ms 192592 KB Output is correct
115 Correct 2691 ms 177872 KB Output is correct
116 Correct 2541 ms 182904 KB Output is correct
117 Correct 1986 ms 183540 KB Output is correct
118 Correct 1695 ms 134172 KB Output is correct
119 Correct 1644 ms 125368 KB Output is correct