Submission #562141

# Submission time Handle Problem Language Result Execution time Memory
562141 2022-05-14T06:28:31 Z piOOE Road Closures (APIO21_roads) C++17
100 / 100
300 ms 58624 KB
#include "roads.h"

#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)

typedef long long ll;

struct fenwick {
    vector<ll> t;
    int n;

    fenwick() = default;

    fenwick(int x) {
        n = x + 1;
        t.assign(n, 0);
    }

    void init(int x) {
        n = x + 1;
        t.assign(n, 0);
    }

    void add(int i, int x) {
        i += 1;
        for (; i < n; i += i & -i)
            t[i] += x;
    }

    ll get(int i) {
        ll ans = 0;
        i += 1;
        i = min(n - 1, i);
        for (; i > 0; i -= i & -i)
            ans += t[i];
        return ans;
    }


    int kth(int k) {
        if (k == 0) return -1;
        int i = 0;
        for (int j = 18; j > -1; --j) {
            if (i + (1 << j) < n && t[i + (1 << j)] < k) {
                i += (1 << j);
                k -= t[i];
            }
        }
        return i;
    }
};

vector<ll> stupid(int n, vector<int> A, vector<int> B, vector<int> W) {
    vector<ll> ans(n);
    vector<vector<pair<int, int>>> g(n);
    for (int i = 0; i < n - 1; ++i) {
        g[A[i]].emplace_back(B[i], W[i]);
        g[B[i]].emplace_back(A[i], W[i]);
    }
    for (int k = 0; k < n; ++k) {
        vector<vector<ll>> dp(n + 1, vector<ll>(2));
        function<void(int, int)> dfs = [&](int v, int p) {
            vector<pair<int, int>> adj;
            for (auto [to, w]: g[v]) {
                if (to != p) {
                    dfs(to, v);
                    adj.emplace_back(to, w);
                }
            }
            if (k > (int) size(adj)) {
                vector<ll> nw;
                ll ans = 0;
                for (auto [to, w]: adj) {
                    ans += dp[to][0] + w;
                    nw.push_back(dp[to][1] - dp[to][0] - w);
                }
                sort(all(nw));
                for (int i = 0; i < (int) size(nw); ++i) {
                    if (nw[i] < 0)
                        ans += nw[i];
                }
                dp[v][1] = dp[v][0] = ans;
            } else {
                vector<ll> nw;
                ll ans = 0;
                for (auto [to, w]: adj) {
                    ans += dp[to][0] + w;
                    nw.push_back(dp[to][1] - dp[to][0] - w);
                }
                sort(all(nw));
                ll added = 0;
                for (int i = 0; i < k - 1; ++i) {
                    if (nw[i] < 0)
                        added += nw[i];
                }
                dp[v][1] = ans + added;
                added = 0;
                for (int i = 0; i < k; ++i) {
                    added += nw[i];
                }
                dp[v][0] = min(dp[v][1], ans + added);
            }
        };
        dfs(0, -1);
        ans[k] = dp[0][0];
    }
    return ans;
}


const int N = 100001;
int A[N], B[N], W[N], n, par[N], sz[N], wp[N], depth[N];
vector<pair<int, int>> g[N], gr[N];
fenwick f1[N], f2[N];
bool used[N];

ll dp[2][N], sm[N];

vector<ll> smart(int nn, vector<int> uu, vector<int> vv, vector<int> ww) {
    n = nn;
    for (int i = 0; i < n; ++i) {
        gr[i].clear(), g[i].clear();
        sm[i] = 0;
    }
    for (int i = 0; i < n - 1; ++i) {
        A[i] = uu[i], B[i] = vv[i], W[i] = ww[i];
        gr[A[i]].emplace_back(-W[i], B[i]);
        gr[B[i]].emplace_back(-W[i], A[i]);
    }
    for (int i = 0; i < n; ++i) {
        sort(all(gr[i]));
        sz[i] = (int) size(gr[i]);
        f1[i].init(sz[i]);
        f2[i].init(sz[i]);
    }
    vector<int> ord(n);
    iota(all(ord), 0);
    sort(all(ord), [](int i, int j) {
        return sz[i] > sz[j];
    });
    function<void(int, int, int)> prec = [&prec](int v, int p, int wep) {
        par[v] = p;
        wp[v] = wep;
        for (auto [w, to]: gr[v]) {
            if (to != p) {
                depth[to] = depth[v] + 1;
                prec(to, v, -w);
            }
        }
    };
    vector<ll> ans(n);
    prec(0, -1, 0);
    for (int k = 0; k < n; ++k) {
        vector<int> now;
        for (int i: ord) {
            if (sz[i] < k) break;
            if (sz[i] == k) {
                for (auto [w, to]: gr[i]) {
                    if (sz[to] <= sz[i]) continue;
                    int id = lower_bound(all(gr[to]), make_pair(w, i)) - begin(gr[to]);
                    assert(id < sz[to] && gr[to][id] == make_pair(w, i));
                    f1[to].add(id, 1);
                    f2[to].add(id, -w);
                    sm[to] += -w;
                }
                continue;
            }
            now.push_back(i);
            used[i] = true;
        }
        for (int x: now) {
            if (par[x] != -1 && used[par[x]]) {
                g[par[x]].emplace_back(x, wp[x]);
            }
        }
        const ll infL = 3e18;
        for (int x: now) used[x] = false;
        function<void(int, int)> dfs = [&](int v, int p) {
            used[v] = true;
            vector<pair<int, int>> adj;
            for (auto [to, w]: g[v]) {
                if (to != p) {
                    dfs(to, v);
                    adj.emplace_back(to, w);
                }
            }
            vector<ll> nw;
            ll sum = 0;
            for (auto [to, w]: adj) {
                nw.push_back(dp[1][to] - dp[0][to] - w);
                sum += dp[0][to] + w;
            }
            sort(all(nw));
            dp[1][v] = dp[0][v] = infL;
            for (int take = 0; take <= min(k, (int) size(nw)); ++take) {
                if (take) {
                    sum += nw[take - 1];
                }
                if (take < k) {
                    int id = f1[v].kth(k - take - 1);
                    ll added = sm[v] - f2[v].get(id);
                    dp[1][v] = min(dp[1][v], sum + added);
                }
                int id = f1[v].kth(k - take);
                ll added = sm[v] - f2[v].get(id);
                dp[0][v] = min(dp[0][v], sum + added);
            }
            dp[0][v] = min(dp[0][v], dp[1][v]);
        };
        sort(all(now), [](int i, int j) {
            return depth[i] < depth[j];
        });
        for (int v: now) {
            if (!used[v]) {
                dfs(v, -1);
                assert(dp[0][v] != infL);
                ans[k] += dp[0][v];
            }
        }
        for (int v: now) {
            used[v] = false;
            g[v].clear();
        }
    }
    return ans;
}

vector<ll> minimum_closure_costs(int nn, vector<int> uu, vector<int> vv, vector<int> ww) {
    n = nn;
    auto smar = smart(nn, uu, vv, ww);
//    auto stup = stupid(nn, uu, vv, ww);
//    if (stup != smar) {
//        cout << n << endl;
//        for (int i = 0; i < n - 1; ++i) {
//            cout << uu[i] << " " << vv[i] << " " << ww[i] << endl;
//        }
//        cout << endl;
//        cout << "stupid: ";
//        for (int x: stup) cout << x << " ";
//        cout << endl;
//        cout << "smart: ";
//        for (int x: smar) cout << x << " ";
//        cout << endl;
//        return {};
//        exit(0);
//    }
    return smar;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11220 KB Output is correct
2 Correct 8 ms 11804 KB Output is correct
3 Correct 8 ms 11768 KB Output is correct
4 Correct 9 ms 11852 KB Output is correct
5 Correct 7 ms 11228 KB Output is correct
6 Correct 7 ms 11348 KB Output is correct
7 Correct 6 ms 11348 KB Output is correct
8 Correct 8 ms 11652 KB Output is correct
9 Correct 8 ms 11732 KB Output is correct
10 Correct 6 ms 11348 KB Output is correct
11 Correct 8 ms 11276 KB Output is correct
12 Correct 86 ms 27020 KB Output is correct
13 Correct 122 ms 37644 KB Output is correct
14 Correct 129 ms 35592 KB Output is correct
15 Correct 165 ms 38068 KB Output is correct
16 Correct 145 ms 38464 KB Output is correct
17 Correct 124 ms 38396 KB Output is correct
18 Correct 6 ms 11220 KB Output is correct
19 Correct 126 ms 35256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 11220 KB Output is correct
2 Correct 105 ms 50764 KB Output is correct
3 Correct 119 ms 55640 KB Output is correct
4 Correct 144 ms 58624 KB Output is correct
5 Correct 149 ms 58620 KB Output is correct
6 Correct 9 ms 12116 KB Output is correct
7 Correct 11 ms 12244 KB Output is correct
8 Correct 9 ms 12192 KB Output is correct
9 Correct 6 ms 11392 KB Output is correct
10 Correct 6 ms 11348 KB Output is correct
11 Correct 6 ms 11348 KB Output is correct
12 Correct 71 ms 39180 KB Output is correct
13 Correct 117 ms 57788 KB Output is correct
14 Correct 7 ms 11348 KB Output is correct
15 Correct 112 ms 53300 KB Output is correct
16 Correct 120 ms 57852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11220 KB Output is correct
2 Correct 7 ms 11276 KB Output is correct
3 Correct 7 ms 11280 KB Output is correct
4 Correct 7 ms 11348 KB Output is correct
5 Correct 7 ms 11284 KB Output is correct
6 Correct 8 ms 11348 KB Output is correct
7 Correct 8 ms 11348 KB Output is correct
8 Correct 6 ms 11348 KB Output is correct
9 Correct 6 ms 11308 KB Output is correct
10 Correct 6 ms 11276 KB Output is correct
11 Correct 6 ms 11348 KB Output is correct
12 Correct 7 ms 11316 KB Output is correct
13 Correct 6 ms 11348 KB Output is correct
14 Correct 7 ms 11356 KB Output is correct
15 Correct 6 ms 11348 KB Output is correct
16 Correct 6 ms 11280 KB Output is correct
17 Correct 6 ms 11272 KB Output is correct
18 Correct 7 ms 11348 KB Output is correct
19 Correct 7 ms 11348 KB Output is correct
20 Correct 7 ms 11348 KB Output is correct
21 Correct 7 ms 11280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11220 KB Output is correct
2 Correct 7 ms 11276 KB Output is correct
3 Correct 7 ms 11280 KB Output is correct
4 Correct 7 ms 11348 KB Output is correct
5 Correct 7 ms 11284 KB Output is correct
6 Correct 8 ms 11348 KB Output is correct
7 Correct 8 ms 11348 KB Output is correct
8 Correct 6 ms 11348 KB Output is correct
9 Correct 6 ms 11308 KB Output is correct
10 Correct 6 ms 11276 KB Output is correct
11 Correct 6 ms 11348 KB Output is correct
12 Correct 7 ms 11316 KB Output is correct
13 Correct 6 ms 11348 KB Output is correct
14 Correct 7 ms 11356 KB Output is correct
15 Correct 6 ms 11348 KB Output is correct
16 Correct 6 ms 11280 KB Output is correct
17 Correct 6 ms 11272 KB Output is correct
18 Correct 7 ms 11348 KB Output is correct
19 Correct 7 ms 11348 KB Output is correct
20 Correct 7 ms 11348 KB Output is correct
21 Correct 7 ms 11280 KB Output is correct
22 Correct 6 ms 11316 KB Output is correct
23 Correct 8 ms 11628 KB Output is correct
24 Correct 9 ms 11848 KB Output is correct
25 Correct 8 ms 11680 KB Output is correct
26 Correct 9 ms 11732 KB Output is correct
27 Correct 8 ms 11860 KB Output is correct
28 Correct 9 ms 11860 KB Output is correct
29 Correct 9 ms 11712 KB Output is correct
30 Correct 9 ms 11732 KB Output is correct
31 Correct 11 ms 11732 KB Output is correct
32 Correct 12 ms 11848 KB Output is correct
33 Correct 9 ms 12084 KB Output is correct
34 Correct 8 ms 12168 KB Output is correct
35 Correct 8 ms 12116 KB Output is correct
36 Correct 9 ms 11804 KB Output is correct
37 Correct 9 ms 11860 KB Output is correct
38 Correct 9 ms 11860 KB Output is correct
39 Correct 8 ms 11280 KB Output is correct
40 Correct 6 ms 11280 KB Output is correct
41 Correct 7 ms 11280 KB Output is correct
42 Correct 6 ms 11348 KB Output is correct
43 Correct 7 ms 11248 KB Output is correct
44 Correct 7 ms 11364 KB Output is correct
45 Correct 8 ms 11348 KB Output is correct
46 Correct 6 ms 11280 KB Output is correct
47 Correct 6 ms 11288 KB Output is correct
48 Correct 6 ms 11364 KB Output is correct
49 Correct 8 ms 11348 KB Output is correct
50 Correct 6 ms 11280 KB Output is correct
51 Correct 6 ms 11348 KB Output is correct
52 Correct 7 ms 11348 KB Output is correct
53 Correct 10 ms 11676 KB Output is correct
54 Correct 12 ms 11732 KB Output is correct
55 Correct 9 ms 11848 KB Output is correct
56 Correct 8 ms 11732 KB Output is correct
57 Correct 8 ms 11800 KB Output is correct
58 Correct 6 ms 11236 KB Output is correct
59 Correct 6 ms 11348 KB Output is correct
60 Correct 6 ms 11348 KB Output is correct
61 Correct 8 ms 11276 KB Output is correct
62 Correct 8 ms 11284 KB Output is correct
63 Correct 6 ms 11220 KB Output is correct
64 Correct 9 ms 11732 KB Output is correct
65 Correct 9 ms 11732 KB Output is correct
66 Correct 8 ms 11816 KB Output is correct
67 Correct 13 ms 11800 KB Output is correct
68 Correct 9 ms 11800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 35296 KB Output is correct
2 Correct 241 ms 34872 KB Output is correct
3 Correct 181 ms 36540 KB Output is correct
4 Correct 229 ms 35904 KB Output is correct
5 Correct 151 ms 36540 KB Output is correct
6 Correct 158 ms 35552 KB Output is correct
7 Correct 197 ms 36076 KB Output is correct
8 Correct 124 ms 36264 KB Output is correct
9 Correct 216 ms 42724 KB Output is correct
10 Correct 217 ms 35192 KB Output is correct
11 Correct 178 ms 36244 KB Output is correct
12 Correct 170 ms 36744 KB Output is correct
13 Correct 7 ms 11320 KB Output is correct
14 Correct 124 ms 53184 KB Output is correct
15 Correct 141 ms 57844 KB Output is correct
16 Correct 9 ms 11804 KB Output is correct
17 Correct 9 ms 11832 KB Output is correct
18 Correct 9 ms 11712 KB Output is correct
19 Correct 9 ms 11732 KB Output is correct
20 Correct 11 ms 11732 KB Output is correct
21 Correct 122 ms 35224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 35296 KB Output is correct
2 Correct 241 ms 34872 KB Output is correct
3 Correct 181 ms 36540 KB Output is correct
4 Correct 229 ms 35904 KB Output is correct
5 Correct 151 ms 36540 KB Output is correct
6 Correct 158 ms 35552 KB Output is correct
7 Correct 197 ms 36076 KB Output is correct
8 Correct 124 ms 36264 KB Output is correct
9 Correct 216 ms 42724 KB Output is correct
10 Correct 217 ms 35192 KB Output is correct
11 Correct 178 ms 36244 KB Output is correct
12 Correct 170 ms 36744 KB Output is correct
13 Correct 7 ms 11320 KB Output is correct
14 Correct 124 ms 53184 KB Output is correct
15 Correct 141 ms 57844 KB Output is correct
16 Correct 9 ms 11804 KB Output is correct
17 Correct 9 ms 11832 KB Output is correct
18 Correct 9 ms 11712 KB Output is correct
19 Correct 9 ms 11732 KB Output is correct
20 Correct 11 ms 11732 KB Output is correct
21 Correct 122 ms 35224 KB Output is correct
22 Correct 7 ms 11220 KB Output is correct
23 Correct 6 ms 11220 KB Output is correct
24 Correct 8 ms 11288 KB Output is correct
25 Correct 226 ms 32616 KB Output is correct
26 Correct 198 ms 30592 KB Output is correct
27 Correct 257 ms 36132 KB Output is correct
28 Correct 196 ms 36548 KB Output is correct
29 Correct 178 ms 34588 KB Output is correct
30 Correct 175 ms 34732 KB Output is correct
31 Correct 193 ms 35772 KB Output is correct
32 Correct 245 ms 33844 KB Output is correct
33 Correct 155 ms 36820 KB Output is correct
34 Correct 231 ms 36088 KB Output is correct
35 Correct 280 ms 44096 KB Output is correct
36 Correct 203 ms 36372 KB Output is correct
37 Correct 206 ms 36768 KB Output is correct
38 Correct 91 ms 39124 KB Output is correct
39 Correct 138 ms 57780 KB Output is correct
40 Correct 10 ms 11664 KB Output is correct
41 Correct 12 ms 11732 KB Output is correct
42 Correct 10 ms 11732 KB Output is correct
43 Correct 10 ms 11732 KB Output is correct
44 Correct 9 ms 11832 KB Output is correct
45 Correct 7 ms 11348 KB Output is correct
46 Correct 8 ms 11276 KB Output is correct
47 Correct 7 ms 11280 KB Output is correct
48 Correct 7 ms 11280 KB Output is correct
49 Correct 7 ms 11256 KB Output is correct
50 Correct 91 ms 27076 KB Output is correct
51 Correct 160 ms 37524 KB Output is correct
52 Correct 300 ms 35188 KB Output is correct
53 Correct 242 ms 34776 KB Output is correct
54 Correct 197 ms 36496 KB Output is correct
55 Correct 272 ms 35980 KB Output is correct
56 Correct 160 ms 36624 KB Output is correct
57 Correct 160 ms 35556 KB Output is correct
58 Correct 221 ms 35988 KB Output is correct
59 Correct 135 ms 36288 KB Output is correct
60 Correct 231 ms 42812 KB Output is correct
61 Correct 262 ms 35308 KB Output is correct
62 Correct 168 ms 36268 KB Output is correct
63 Correct 153 ms 36852 KB Output is correct
64 Correct 9 ms 11284 KB Output is correct
65 Correct 113 ms 53300 KB Output is correct
66 Correct 131 ms 57732 KB Output is correct
67 Correct 10 ms 11732 KB Output is correct
68 Correct 10 ms 11804 KB Output is correct
69 Correct 11 ms 11820 KB Output is correct
70 Correct 11 ms 11732 KB Output is correct
71 Correct 8 ms 11800 KB Output is correct
72 Correct 113 ms 35252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11220 KB Output is correct
2 Correct 8 ms 11804 KB Output is correct
3 Correct 8 ms 11768 KB Output is correct
4 Correct 9 ms 11852 KB Output is correct
5 Correct 7 ms 11228 KB Output is correct
6 Correct 7 ms 11348 KB Output is correct
7 Correct 6 ms 11348 KB Output is correct
8 Correct 8 ms 11652 KB Output is correct
9 Correct 8 ms 11732 KB Output is correct
10 Correct 6 ms 11348 KB Output is correct
11 Correct 8 ms 11276 KB Output is correct
12 Correct 86 ms 27020 KB Output is correct
13 Correct 122 ms 37644 KB Output is correct
14 Correct 129 ms 35592 KB Output is correct
15 Correct 165 ms 38068 KB Output is correct
16 Correct 145 ms 38464 KB Output is correct
17 Correct 124 ms 38396 KB Output is correct
18 Correct 6 ms 11220 KB Output is correct
19 Correct 126 ms 35256 KB Output is correct
20 Correct 7 ms 11220 KB Output is correct
21 Correct 105 ms 50764 KB Output is correct
22 Correct 119 ms 55640 KB Output is correct
23 Correct 144 ms 58624 KB Output is correct
24 Correct 149 ms 58620 KB Output is correct
25 Correct 9 ms 12116 KB Output is correct
26 Correct 11 ms 12244 KB Output is correct
27 Correct 9 ms 12192 KB Output is correct
28 Correct 6 ms 11392 KB Output is correct
29 Correct 6 ms 11348 KB Output is correct
30 Correct 6 ms 11348 KB Output is correct
31 Correct 71 ms 39180 KB Output is correct
32 Correct 117 ms 57788 KB Output is correct
33 Correct 7 ms 11348 KB Output is correct
34 Correct 112 ms 53300 KB Output is correct
35 Correct 120 ms 57852 KB Output is correct
36 Correct 6 ms 11220 KB Output is correct
37 Correct 7 ms 11276 KB Output is correct
38 Correct 7 ms 11280 KB Output is correct
39 Correct 7 ms 11348 KB Output is correct
40 Correct 7 ms 11284 KB Output is correct
41 Correct 8 ms 11348 KB Output is correct
42 Correct 8 ms 11348 KB Output is correct
43 Correct 6 ms 11348 KB Output is correct
44 Correct 6 ms 11308 KB Output is correct
45 Correct 6 ms 11276 KB Output is correct
46 Correct 6 ms 11348 KB Output is correct
47 Correct 7 ms 11316 KB Output is correct
48 Correct 6 ms 11348 KB Output is correct
49 Correct 7 ms 11356 KB Output is correct
50 Correct 6 ms 11348 KB Output is correct
51 Correct 6 ms 11280 KB Output is correct
52 Correct 6 ms 11272 KB Output is correct
53 Correct 7 ms 11348 KB Output is correct
54 Correct 7 ms 11348 KB Output is correct
55 Correct 7 ms 11348 KB Output is correct
56 Correct 7 ms 11280 KB Output is correct
57 Correct 6 ms 11316 KB Output is correct
58 Correct 8 ms 11628 KB Output is correct
59 Correct 9 ms 11848 KB Output is correct
60 Correct 8 ms 11680 KB Output is correct
61 Correct 9 ms 11732 KB Output is correct
62 Correct 8 ms 11860 KB Output is correct
63 Correct 9 ms 11860 KB Output is correct
64 Correct 9 ms 11712 KB Output is correct
65 Correct 9 ms 11732 KB Output is correct
66 Correct 11 ms 11732 KB Output is correct
67 Correct 12 ms 11848 KB Output is correct
68 Correct 9 ms 12084 KB Output is correct
69 Correct 8 ms 12168 KB Output is correct
70 Correct 8 ms 12116 KB Output is correct
71 Correct 9 ms 11804 KB Output is correct
72 Correct 9 ms 11860 KB Output is correct
73 Correct 9 ms 11860 KB Output is correct
74 Correct 8 ms 11280 KB Output is correct
75 Correct 6 ms 11280 KB Output is correct
76 Correct 7 ms 11280 KB Output is correct
77 Correct 6 ms 11348 KB Output is correct
78 Correct 7 ms 11248 KB Output is correct
79 Correct 7 ms 11364 KB Output is correct
80 Correct 8 ms 11348 KB Output is correct
81 Correct 6 ms 11280 KB Output is correct
82 Correct 6 ms 11288 KB Output is correct
83 Correct 6 ms 11364 KB Output is correct
84 Correct 8 ms 11348 KB Output is correct
85 Correct 6 ms 11280 KB Output is correct
86 Correct 6 ms 11348 KB Output is correct
87 Correct 7 ms 11348 KB Output is correct
88 Correct 10 ms 11676 KB Output is correct
89 Correct 12 ms 11732 KB Output is correct
90 Correct 9 ms 11848 KB Output is correct
91 Correct 8 ms 11732 KB Output is correct
92 Correct 8 ms 11800 KB Output is correct
93 Correct 6 ms 11236 KB Output is correct
94 Correct 6 ms 11348 KB Output is correct
95 Correct 6 ms 11348 KB Output is correct
96 Correct 8 ms 11276 KB Output is correct
97 Correct 8 ms 11284 KB Output is correct
98 Correct 6 ms 11220 KB Output is correct
99 Correct 9 ms 11732 KB Output is correct
100 Correct 9 ms 11732 KB Output is correct
101 Correct 8 ms 11816 KB Output is correct
102 Correct 13 ms 11800 KB Output is correct
103 Correct 9 ms 11800 KB Output is correct
104 Correct 249 ms 35296 KB Output is correct
105 Correct 241 ms 34872 KB Output is correct
106 Correct 181 ms 36540 KB Output is correct
107 Correct 229 ms 35904 KB Output is correct
108 Correct 151 ms 36540 KB Output is correct
109 Correct 158 ms 35552 KB Output is correct
110 Correct 197 ms 36076 KB Output is correct
111 Correct 124 ms 36264 KB Output is correct
112 Correct 216 ms 42724 KB Output is correct
113 Correct 217 ms 35192 KB Output is correct
114 Correct 178 ms 36244 KB Output is correct
115 Correct 170 ms 36744 KB Output is correct
116 Correct 7 ms 11320 KB Output is correct
117 Correct 124 ms 53184 KB Output is correct
118 Correct 141 ms 57844 KB Output is correct
119 Correct 9 ms 11804 KB Output is correct
120 Correct 9 ms 11832 KB Output is correct
121 Correct 9 ms 11712 KB Output is correct
122 Correct 9 ms 11732 KB Output is correct
123 Correct 11 ms 11732 KB Output is correct
124 Correct 122 ms 35224 KB Output is correct
125 Correct 7 ms 11220 KB Output is correct
126 Correct 6 ms 11220 KB Output is correct
127 Correct 8 ms 11288 KB Output is correct
128 Correct 226 ms 32616 KB Output is correct
129 Correct 198 ms 30592 KB Output is correct
130 Correct 257 ms 36132 KB Output is correct
131 Correct 196 ms 36548 KB Output is correct
132 Correct 178 ms 34588 KB Output is correct
133 Correct 175 ms 34732 KB Output is correct
134 Correct 193 ms 35772 KB Output is correct
135 Correct 245 ms 33844 KB Output is correct
136 Correct 155 ms 36820 KB Output is correct
137 Correct 231 ms 36088 KB Output is correct
138 Correct 280 ms 44096 KB Output is correct
139 Correct 203 ms 36372 KB Output is correct
140 Correct 206 ms 36768 KB Output is correct
141 Correct 91 ms 39124 KB Output is correct
142 Correct 138 ms 57780 KB Output is correct
143 Correct 10 ms 11664 KB Output is correct
144 Correct 12 ms 11732 KB Output is correct
145 Correct 10 ms 11732 KB Output is correct
146 Correct 10 ms 11732 KB Output is correct
147 Correct 9 ms 11832 KB Output is correct
148 Correct 7 ms 11348 KB Output is correct
149 Correct 8 ms 11276 KB Output is correct
150 Correct 7 ms 11280 KB Output is correct
151 Correct 7 ms 11280 KB Output is correct
152 Correct 7 ms 11256 KB Output is correct
153 Correct 91 ms 27076 KB Output is correct
154 Correct 160 ms 37524 KB Output is correct
155 Correct 300 ms 35188 KB Output is correct
156 Correct 242 ms 34776 KB Output is correct
157 Correct 197 ms 36496 KB Output is correct
158 Correct 272 ms 35980 KB Output is correct
159 Correct 160 ms 36624 KB Output is correct
160 Correct 160 ms 35556 KB Output is correct
161 Correct 221 ms 35988 KB Output is correct
162 Correct 135 ms 36288 KB Output is correct
163 Correct 231 ms 42812 KB Output is correct
164 Correct 262 ms 35308 KB Output is correct
165 Correct 168 ms 36268 KB Output is correct
166 Correct 153 ms 36852 KB Output is correct
167 Correct 9 ms 11284 KB Output is correct
168 Correct 113 ms 53300 KB Output is correct
169 Correct 131 ms 57732 KB Output is correct
170 Correct 10 ms 11732 KB Output is correct
171 Correct 10 ms 11804 KB Output is correct
172 Correct 11 ms 11820 KB Output is correct
173 Correct 11 ms 11732 KB Output is correct
174 Correct 8 ms 11800 KB Output is correct
175 Correct 113 ms 35252 KB Output is correct
176 Correct 8 ms 11220 KB Output is correct
177 Correct 237 ms 36568 KB Output is correct
178 Correct 191 ms 31032 KB Output is correct
179 Correct 182 ms 36532 KB Output is correct
180 Correct 160 ms 35776 KB Output is correct
181 Correct 187 ms 37516 KB Output is correct
182 Correct 159 ms 37264 KB Output is correct
183 Correct 185 ms 36216 KB Output is correct
184 Correct 187 ms 35448 KB Output is correct
185 Correct 173 ms 35568 KB Output is correct
186 Correct 157 ms 34756 KB Output is correct
187 Correct 178 ms 38808 KB Output is correct
188 Correct 227 ms 34944 KB Output is correct
189 Correct 211 ms 34912 KB Output is correct
190 Correct 221 ms 37072 KB Output is correct
191 Correct 157 ms 36216 KB Output is correct
192 Correct 169 ms 37656 KB Output is correct
193 Correct 181 ms 37752 KB Output is correct
194 Correct 186 ms 37140 KB Output is correct
195 Correct 113 ms 50792 KB Output is correct
196 Correct 126 ms 55584 KB Output is correct
197 Correct 147 ms 58612 KB Output is correct
198 Correct 147 ms 58620 KB Output is correct
199 Correct 9 ms 11572 KB Output is correct
200 Correct 11 ms 11804 KB Output is correct
201 Correct 9 ms 11696 KB Output is correct
202 Correct 11 ms 11808 KB Output is correct
203 Correct 9 ms 11804 KB Output is correct
204 Correct 10 ms 11804 KB Output is correct
205 Correct 11 ms 11752 KB Output is correct
206 Correct 10 ms 11732 KB Output is correct
207 Correct 9 ms 11732 KB Output is correct
208 Correct 9 ms 11804 KB Output is correct
209 Correct 10 ms 12092 KB Output is correct
210 Correct 11 ms 12244 KB Output is correct
211 Correct 10 ms 12056 KB Output is correct
212 Correct 10 ms 11800 KB Output is correct
213 Correct 11 ms 11852 KB Output is correct
214 Correct 9 ms 11860 KB Output is correct
215 Correct 6 ms 11260 KB Output is correct
216 Correct 8 ms 11220 KB Output is correct
217 Correct 8 ms 11276 KB Output is correct
218 Correct 6 ms 11276 KB Output is correct
219 Correct 6 ms 11276 KB Output is correct
220 Correct 8 ms 11328 KB Output is correct
221 Correct 7 ms 11348 KB Output is correct
222 Correct 6 ms 11348 KB Output is correct
223 Correct 6 ms 11348 KB Output is correct
224 Correct 9 ms 11404 KB Output is correct
225 Correct 8 ms 11316 KB Output is correct
226 Correct 7 ms 11348 KB Output is correct
227 Correct 7 ms 11348 KB Output is correct
228 Correct 6 ms 11280 KB Output is correct
229 Correct 194 ms 32584 KB Output is correct
230 Correct 185 ms 30476 KB Output is correct
231 Correct 259 ms 36144 KB Output is correct
232 Correct 184 ms 36584 KB Output is correct
233 Correct 152 ms 34628 KB Output is correct
234 Correct 157 ms 34676 KB Output is correct
235 Correct 152 ms 35692 KB Output is correct
236 Correct 217 ms 33900 KB Output is correct
237 Correct 142 ms 36852 KB Output is correct
238 Correct 202 ms 36088 KB Output is correct
239 Correct 258 ms 44004 KB Output is correct
240 Correct 188 ms 36244 KB Output is correct
241 Correct 183 ms 36804 KB Output is correct
242 Correct 82 ms 39184 KB Output is correct
243 Correct 135 ms 57796 KB Output is correct
244 Correct 11 ms 11676 KB Output is correct
245 Correct 10 ms 11824 KB Output is correct
246 Correct 9 ms 11732 KB Output is correct
247 Correct 8 ms 11732 KB Output is correct
248 Correct 9 ms 11804 KB Output is correct
249 Correct 8 ms 11348 KB Output is correct
250 Correct 7 ms 11244 KB Output is correct
251 Correct 7 ms 11284 KB Output is correct
252 Correct 8 ms 11276 KB Output is correct
253 Correct 6 ms 11276 KB Output is correct
254 Correct 99 ms 27080 KB Output is correct
255 Correct 144 ms 37648 KB Output is correct
256 Correct 142 ms 35452 KB Output is correct
257 Correct 165 ms 38064 KB Output is correct
258 Correct 167 ms 38396 KB Output is correct
259 Correct 161 ms 38560 KB Output is correct
260 Correct 253 ms 35240 KB Output is correct
261 Correct 226 ms 34768 KB Output is correct
262 Correct 180 ms 36536 KB Output is correct
263 Correct 262 ms 36100 KB Output is correct
264 Correct 157 ms 36628 KB Output is correct
265 Correct 146 ms 35592 KB Output is correct
266 Correct 220 ms 36076 KB Output is correct
267 Correct 124 ms 36348 KB Output is correct
268 Correct 246 ms 42808 KB Output is correct
269 Correct 234 ms 35308 KB Output is correct
270 Correct 185 ms 36292 KB Output is correct
271 Correct 155 ms 36824 KB Output is correct
272 Correct 7 ms 11276 KB Output is correct
273 Correct 123 ms 53256 KB Output is correct
274 Correct 140 ms 57728 KB Output is correct
275 Correct 9 ms 11732 KB Output is correct
276 Correct 11 ms 11748 KB Output is correct
277 Correct 11 ms 11800 KB Output is correct
278 Correct 9 ms 11800 KB Output is correct
279 Correct 11 ms 11776 KB Output is correct
280 Correct 123 ms 35212 KB Output is correct