Submission #963027

# Submission time Handle Problem Language Result Execution time Memory
963027 2024-04-14T11:19:45 Z Mtaylor Tourism (JOI23_tourism) C++17
100 / 100
1222 ms 53224 KB
// Mtaylor
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define endl '\n';
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
typedef long long ll;
const int N = 3e5 + 5;
template <typename T>
class FenwickTree {
   public:
    vector<T> tree;
    int n;
    void init(int n) {
        tree.assign(n + 2, 0);
        this->n = n;
    }
    T mrg(T &x, T &y) { return x + y; }

    void upd(int x, T v) {
        for (; x <= n; x += (x) & (-x)) {
            tree[x] = mrg(tree[x], v);
        }
    }
    T getprefix(int x) {
        if (x <= 0) return 0;
        T rs = 0;
        for (; x; x -= (x) & (-x)) {
            rs = mrg(rs, tree[x]);
        }
        return rs;
    }
    T getrange(int l, int r) { return getprefix(r) - getprefix(l - 1); }
};
FenwickTree<ll> ft;
int nxt[N];
int val[N];
set<int> intervals;

void updateAns(int l, int r, int x) {
    set<int>::iterator it;
    it = intervals.lower_bound(l);
    if (it != intervals.begin()) it--;
    vector<int> to_rem;
    vector<int> to_add;
    while (it != intervals.end()) {
        int a = *it;
        int b = nxt[a];
        if (a > r) break;
        if (a < l && b < l) {
            it++;
            continue;
        }
        if (a < l) {
            ft.upd(val[a], -(b - a + 1));
            nxt[a] = l - 1;
            ft.upd(val[a], (nxt[a] - a + 1));
        } else {
            ft.upd(val[a], -(b - a + 1));
            to_rem.pb(a);
        }
        if (b > r) {
            to_add.pb(r + 1);
            val[r+1]=val[a];
            ft.upd(val[a], b - r);
            nxt[r + 1] = b;
        }
        it++;
    }
    nxt[l] = r;
    val[l] = x;
    ft.upd(x, r - l + 1);
    for (auto &u : to_rem) {
        assert(intervals.count(u));
        intervals.erase(u);
    }
    for (auto &u : to_add) {
        intervals.insert(u);
    }
    intervals.insert(l);
}

const int E = 1e6 + 5;

#define neig(u, v, e, g) for (int e = g.head[u], v; ~e && ((v = g.to[e]), 1); e = g.nxt[e])

class ADJ {
   public:
    int head[E], to[E], nxt[E], n, edgcnt = 0;
    ll cst[E];

    void addEdge(int a, int b, int c = 0) {
        nxt[edgcnt] = head[a];
        head[a] = edgcnt;
        to[edgcnt] = b;
        cst[edgcnt] = c;
        edgcnt++;
    }

    void addBiEdge(int a, int b, int c = 0) {
        addEdge(a, b, c);
        addEdge(b, a, c);
    }
    void init(int _n) {
        n = _n;
        memset(head, -1, n * sizeof(head[0]));
        edgcnt = 0;
    }
} adj;

class HLD {
   public:
    vector<int> par, sze, dpth, ndToIdx, chHead, heavyChld, idxToNd;
    int n, curPos;
    HLD() {}
    void run(ADJ &adj) {
        n = adj.n;
        curPos = 0;
        par.assign(n, -1);
        sze.assign(n, 0);
        dpth.assign(n, 0);
        ndToIdx.assign(n, 0);
        chHead.assign(n, 0);
        heavyChld.assign(n, 0);
        idxToNd.assign(n, 0);
        calcsz(0, adj);
        HLD_util(0, adj);
    }
    void calcsz(int u, ADJ &adj) {
        heavyChld[u] = -1;
        sze[u] = 1;
        int mx = 0, mxv;
        neig(u, v, e, adj) {
            if (par[u] == v) continue;
            par[v] = u;
            dpth[v] = dpth[u] + 1;
            calcsz(v, adj);
            if (sze[v] > mx) {
                mx = sze[v];
                mxv = v;
            }
            sze[u] += sze[v];
        }
        if (mx * 2 > sze[u]) {
            heavyChld[u] = mxv;
        }
    }

    void HLD_util(int u, ADJ &adj, int c = 0) {
        if (u == -1) return;
        idxToNd[curPos] = u;
        ndToIdx[u] = curPos++;
        chHead[u] = c;
        HLD_util(heavyChld[u], adj, c);
        neig(u, v, e, adj) {
            if (v == par[u]) continue;
            if (v == heavyChld[u]) continue;
            HLD_util(v, adj, v);
        }
    }
    int lca(int u, int v) {
        while (chHead[u] != chHead[v]) {
            if (dpth[chHead[v]] > dpth[chHead[u]]) swap(u, v);
            u = par[chHead[u]];
        }
        if (dpth[u] > dpth[v]) swap(u, v);
        return u;
    }
    int getDist(int u, int v) {
        int l = lca(u, v);
        return dpth[u] + dpth[v] - 2 * dpth[l];
    }
    void update(int u, int v, int x) {
        while (chHead[u] != chHead[v]) {
            if (dpth[chHead[v]] > dpth[chHead[u]]) {
                swap(u, v);
            }
            updateAns(ndToIdx[chHead[u]], ndToIdx[u], x);
            u = par[chHead[u]];
        }
        if (dpth[u] > dpth[v]) {
            swap(u, v);
        }
        updateAns(ndToIdx[u], ndToIdx[v], x);
    }
} hld;

int n, m, q;
int c[N];
vector<int> qu[N];
int l[N], r[N];
ll ans[N];
void test_case() {
    cin >> n >> m >> q;
    adj.init(n);
    ft.init(m + 2);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        adj.addBiEdge(u, v);
    }

    hld.run(adj);
    for (int i = 1; i <= m; i++) {
        cin >> c[i];
        --c[i];
    }
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        qu[r[i]].pb(i);
    }
    for (int i = 1; i <= m; i++) {
        if (i >= 2) {
            hld.update(c[i - 1], c[i], i - 1);
        }
        hld.update(c[i], c[i], i);
        for (auto &id : qu[i]) {
            ans[id] = ft.getrange(l[id], m + 2);
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << "\n";
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    while (T--) {
        test_case();
    }
    return 0;
}

Compilation message

tourism.cpp: In member function 'void HLD::calcsz(int, ADJ&)':
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp: In function 'void test_case()':
tourism.cpp:158:26: warning: 'mxv' may be used uninitialized in this function [-Wmaybe-uninitialized]
  158 |             heavyChld[u] = mxv;
tourism.cpp:145:21: note: 'mxv' was declared here
  145 |         int mx = 0, mxv;
      |                     ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 21080 KB Output is correct
2 Correct 3 ms 20828 KB Output is correct
3 Correct 4 ms 20828 KB Output is correct
4 Correct 5 ms 20828 KB Output is correct
5 Correct 3 ms 20828 KB Output is correct
6 Correct 4 ms 20828 KB Output is correct
7 Correct 3 ms 20828 KB Output is correct
8 Correct 5 ms 20828 KB Output is correct
9 Correct 4 ms 20828 KB Output is correct
10 Correct 4 ms 21080 KB Output is correct
11 Correct 5 ms 20976 KB Output is correct
12 Correct 4 ms 20828 KB Output is correct
13 Correct 4 ms 20972 KB Output is correct
14 Correct 4 ms 20824 KB Output is correct
15 Correct 4 ms 20980 KB Output is correct
16 Correct 3 ms 20824 KB Output is correct
17 Correct 4 ms 20824 KB Output is correct
18 Correct 4 ms 20980 KB Output is correct
19 Correct 4 ms 20828 KB Output is correct
20 Correct 4 ms 20924 KB Output is correct
21 Correct 4 ms 20824 KB Output is correct
22 Correct 5 ms 20828 KB Output is correct
23 Correct 4 ms 20828 KB Output is correct
24 Correct 4 ms 21024 KB Output is correct
25 Correct 4 ms 20828 KB Output is correct
26 Correct 4 ms 20980 KB Output is correct
27 Correct 3 ms 16732 KB Output is correct
28 Correct 3 ms 20828 KB Output is correct
29 Correct 4 ms 20828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 21080 KB Output is correct
2 Correct 3 ms 20828 KB Output is correct
3 Correct 4 ms 20828 KB Output is correct
4 Correct 5 ms 20828 KB Output is correct
5 Correct 3 ms 20828 KB Output is correct
6 Correct 4 ms 20828 KB Output is correct
7 Correct 3 ms 20828 KB Output is correct
8 Correct 5 ms 20828 KB Output is correct
9 Correct 4 ms 20828 KB Output is correct
10 Correct 4 ms 21080 KB Output is correct
11 Correct 5 ms 20976 KB Output is correct
12 Correct 4 ms 20828 KB Output is correct
13 Correct 4 ms 20972 KB Output is correct
14 Correct 4 ms 20824 KB Output is correct
15 Correct 4 ms 20980 KB Output is correct
16 Correct 3 ms 20824 KB Output is correct
17 Correct 4 ms 20824 KB Output is correct
18 Correct 4 ms 20980 KB Output is correct
19 Correct 4 ms 20828 KB Output is correct
20 Correct 4 ms 20924 KB Output is correct
21 Correct 4 ms 20824 KB Output is correct
22 Correct 5 ms 20828 KB Output is correct
23 Correct 4 ms 20828 KB Output is correct
24 Correct 4 ms 21024 KB Output is correct
25 Correct 4 ms 20828 KB Output is correct
26 Correct 4 ms 20980 KB Output is correct
27 Correct 3 ms 16732 KB Output is correct
28 Correct 3 ms 20828 KB Output is correct
29 Correct 4 ms 20828 KB Output is correct
30 Correct 8 ms 21080 KB Output is correct
31 Correct 11 ms 21340 KB Output is correct
32 Correct 10 ms 21080 KB Output is correct
33 Correct 11 ms 21080 KB Output is correct
34 Correct 9 ms 21084 KB Output is correct
35 Correct 9 ms 21084 KB Output is correct
36 Correct 9 ms 21080 KB Output is correct
37 Correct 9 ms 21080 KB Output is correct
38 Correct 6 ms 21340 KB Output is correct
39 Correct 6 ms 21340 KB Output is correct
40 Correct 6 ms 21340 KB Output is correct
41 Correct 5 ms 21340 KB Output is correct
42 Correct 6 ms 21340 KB Output is correct
43 Correct 5 ms 21340 KB Output is correct
44 Correct 7 ms 21084 KB Output is correct
45 Correct 9 ms 21256 KB Output is correct
46 Correct 9 ms 21084 KB Output is correct
47 Correct 7 ms 21084 KB Output is correct
48 Correct 7 ms 21196 KB Output is correct
49 Correct 7 ms 21084 KB Output is correct
50 Correct 8 ms 21080 KB Output is correct
51 Correct 6 ms 21084 KB Output is correct
52 Correct 6 ms 21336 KB Output is correct
53 Correct 6 ms 21184 KB Output is correct
54 Correct 7 ms 21084 KB Output is correct
55 Correct 6 ms 21080 KB Output is correct
56 Correct 3 ms 16732 KB Output is correct
57 Correct 4 ms 21084 KB Output is correct
58 Correct 11 ms 21088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 4 ms 16728 KB Output is correct
4 Correct 104 ms 41812 KB Output is correct
5 Correct 85 ms 46672 KB Output is correct
6 Correct 100 ms 49492 KB Output is correct
7 Correct 161 ms 53224 KB Output is correct
8 Correct 132 ms 53004 KB Output is correct
9 Correct 140 ms 53072 KB Output is correct
10 Correct 133 ms 53148 KB Output is correct
11 Correct 146 ms 53144 KB Output is correct
12 Correct 135 ms 52104 KB Output is correct
13 Correct 141 ms 52076 KB Output is correct
14 Correct 134 ms 52052 KB Output is correct
15 Correct 43 ms 48872 KB Output is correct
16 Correct 146 ms 52848 KB Output is correct
17 Correct 48 ms 23120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 20824 KB Output is correct
2 Correct 302 ms 26784 KB Output is correct
3 Correct 476 ms 27588 KB Output is correct
4 Correct 369 ms 28976 KB Output is correct
5 Correct 630 ms 31828 KB Output is correct
6 Correct 591 ms 31708 KB Output is correct
7 Correct 610 ms 31680 KB Output is correct
8 Correct 590 ms 31768 KB Output is correct
9 Correct 607 ms 31876 KB Output is correct
10 Correct 624 ms 31956 KB Output is correct
11 Correct 592 ms 31708 KB Output is correct
12 Correct 591 ms 31944 KB Output is correct
13 Correct 623 ms 32140 KB Output is correct
14 Correct 649 ms 35192 KB Output is correct
15 Correct 616 ms 38484 KB Output is correct
16 Correct 583 ms 32120 KB Output is correct
17 Correct 634 ms 32200 KB Output is correct
18 Correct 572 ms 32384 KB Output is correct
19 Correct 339 ms 29528 KB Output is correct
20 Correct 329 ms 29420 KB Output is correct
21 Correct 348 ms 29056 KB Output is correct
22 Correct 343 ms 29508 KB Output is correct
23 Correct 332 ms 29224 KB Output is correct
24 Correct 332 ms 29468 KB Output is correct
25 Correct 321 ms 29196 KB Output is correct
26 Correct 337 ms 29236 KB Output is correct
27 Correct 335 ms 29268 KB Output is correct
28 Correct 334 ms 29212 KB Output is correct
29 Correct 362 ms 29272 KB Output is correct
30 Correct 350 ms 29792 KB Output is correct
31 Correct 332 ms 29696 KB Output is correct
32 Correct 341 ms 30344 KB Output is correct
33 Correct 351 ms 33496 KB Output is correct
34 Correct 340 ms 36160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 20828 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 3 ms 16988 KB Output is correct
4 Correct 928 ms 34780 KB Output is correct
5 Correct 972 ms 34752 KB Output is correct
6 Correct 1108 ms 37300 KB Output is correct
7 Correct 1168 ms 38072 KB Output is correct
8 Correct 1166 ms 38040 KB Output is correct
9 Correct 1181 ms 38076 KB Output is correct
10 Correct 1166 ms 38232 KB Output is correct
11 Correct 1222 ms 38124 KB Output is correct
12 Correct 1186 ms 38096 KB Output is correct
13 Correct 1162 ms 38128 KB Output is correct
14 Correct 56 ms 23024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 21080 KB Output is correct
2 Correct 3 ms 20828 KB Output is correct
3 Correct 4 ms 20828 KB Output is correct
4 Correct 5 ms 20828 KB Output is correct
5 Correct 3 ms 20828 KB Output is correct
6 Correct 4 ms 20828 KB Output is correct
7 Correct 3 ms 20828 KB Output is correct
8 Correct 5 ms 20828 KB Output is correct
9 Correct 4 ms 20828 KB Output is correct
10 Correct 4 ms 21080 KB Output is correct
11 Correct 5 ms 20976 KB Output is correct
12 Correct 4 ms 20828 KB Output is correct
13 Correct 4 ms 20972 KB Output is correct
14 Correct 4 ms 20824 KB Output is correct
15 Correct 4 ms 20980 KB Output is correct
16 Correct 3 ms 20824 KB Output is correct
17 Correct 4 ms 20824 KB Output is correct
18 Correct 4 ms 20980 KB Output is correct
19 Correct 4 ms 20828 KB Output is correct
20 Correct 4 ms 20924 KB Output is correct
21 Correct 4 ms 20824 KB Output is correct
22 Correct 5 ms 20828 KB Output is correct
23 Correct 4 ms 20828 KB Output is correct
24 Correct 4 ms 21024 KB Output is correct
25 Correct 4 ms 20828 KB Output is correct
26 Correct 4 ms 20980 KB Output is correct
27 Correct 3 ms 16732 KB Output is correct
28 Correct 3 ms 20828 KB Output is correct
29 Correct 4 ms 20828 KB Output is correct
30 Correct 8 ms 21080 KB Output is correct
31 Correct 11 ms 21340 KB Output is correct
32 Correct 10 ms 21080 KB Output is correct
33 Correct 11 ms 21080 KB Output is correct
34 Correct 9 ms 21084 KB Output is correct
35 Correct 9 ms 21084 KB Output is correct
36 Correct 9 ms 21080 KB Output is correct
37 Correct 9 ms 21080 KB Output is correct
38 Correct 6 ms 21340 KB Output is correct
39 Correct 6 ms 21340 KB Output is correct
40 Correct 6 ms 21340 KB Output is correct
41 Correct 5 ms 21340 KB Output is correct
42 Correct 6 ms 21340 KB Output is correct
43 Correct 5 ms 21340 KB Output is correct
44 Correct 7 ms 21084 KB Output is correct
45 Correct 9 ms 21256 KB Output is correct
46 Correct 9 ms 21084 KB Output is correct
47 Correct 7 ms 21084 KB Output is correct
48 Correct 7 ms 21196 KB Output is correct
49 Correct 7 ms 21084 KB Output is correct
50 Correct 8 ms 21080 KB Output is correct
51 Correct 6 ms 21084 KB Output is correct
52 Correct 6 ms 21336 KB Output is correct
53 Correct 6 ms 21184 KB Output is correct
54 Correct 7 ms 21084 KB Output is correct
55 Correct 6 ms 21080 KB Output is correct
56 Correct 3 ms 16732 KB Output is correct
57 Correct 4 ms 21084 KB Output is correct
58 Correct 11 ms 21088 KB Output is correct
59 Correct 3 ms 20828 KB Output is correct
60 Correct 3 ms 16732 KB Output is correct
61 Correct 4 ms 16728 KB Output is correct
62 Correct 104 ms 41812 KB Output is correct
63 Correct 85 ms 46672 KB Output is correct
64 Correct 100 ms 49492 KB Output is correct
65 Correct 161 ms 53224 KB Output is correct
66 Correct 132 ms 53004 KB Output is correct
67 Correct 140 ms 53072 KB Output is correct
68 Correct 133 ms 53148 KB Output is correct
69 Correct 146 ms 53144 KB Output is correct
70 Correct 135 ms 52104 KB Output is correct
71 Correct 141 ms 52076 KB Output is correct
72 Correct 134 ms 52052 KB Output is correct
73 Correct 43 ms 48872 KB Output is correct
74 Correct 146 ms 52848 KB Output is correct
75 Correct 48 ms 23120 KB Output is correct
76 Correct 3 ms 20824 KB Output is correct
77 Correct 302 ms 26784 KB Output is correct
78 Correct 476 ms 27588 KB Output is correct
79 Correct 369 ms 28976 KB Output is correct
80 Correct 630 ms 31828 KB Output is correct
81 Correct 591 ms 31708 KB Output is correct
82 Correct 610 ms 31680 KB Output is correct
83 Correct 590 ms 31768 KB Output is correct
84 Correct 607 ms 31876 KB Output is correct
85 Correct 624 ms 31956 KB Output is correct
86 Correct 592 ms 31708 KB Output is correct
87 Correct 591 ms 31944 KB Output is correct
88 Correct 623 ms 32140 KB Output is correct
89 Correct 649 ms 35192 KB Output is correct
90 Correct 616 ms 38484 KB Output is correct
91 Correct 583 ms 32120 KB Output is correct
92 Correct 634 ms 32200 KB Output is correct
93 Correct 572 ms 32384 KB Output is correct
94 Correct 339 ms 29528 KB Output is correct
95 Correct 329 ms 29420 KB Output is correct
96 Correct 348 ms 29056 KB Output is correct
97 Correct 343 ms 29508 KB Output is correct
98 Correct 332 ms 29224 KB Output is correct
99 Correct 332 ms 29468 KB Output is correct
100 Correct 321 ms 29196 KB Output is correct
101 Correct 337 ms 29236 KB Output is correct
102 Correct 335 ms 29268 KB Output is correct
103 Correct 334 ms 29212 KB Output is correct
104 Correct 362 ms 29272 KB Output is correct
105 Correct 350 ms 29792 KB Output is correct
106 Correct 332 ms 29696 KB Output is correct
107 Correct 341 ms 30344 KB Output is correct
108 Correct 351 ms 33496 KB Output is correct
109 Correct 340 ms 36160 KB Output is correct
110 Correct 3 ms 20828 KB Output is correct
111 Correct 3 ms 16732 KB Output is correct
112 Correct 3 ms 16988 KB Output is correct
113 Correct 928 ms 34780 KB Output is correct
114 Correct 972 ms 34752 KB Output is correct
115 Correct 1108 ms 37300 KB Output is correct
116 Correct 1168 ms 38072 KB Output is correct
117 Correct 1166 ms 38040 KB Output is correct
118 Correct 1181 ms 38076 KB Output is correct
119 Correct 1166 ms 38232 KB Output is correct
120 Correct 1222 ms 38124 KB Output is correct
121 Correct 1186 ms 38096 KB Output is correct
122 Correct 1162 ms 38128 KB Output is correct
123 Correct 56 ms 23024 KB Output is correct
124 Correct 572 ms 36712 KB Output is correct
125 Correct 400 ms 34708 KB Output is correct
126 Correct 638 ms 37512 KB Output is correct
127 Correct 655 ms 37572 KB Output is correct
128 Correct 661 ms 37428 KB Output is correct
129 Correct 638 ms 37676 KB Output is correct
130 Correct 629 ms 37540 KB Output is correct
131 Correct 161 ms 50336 KB Output is correct
132 Correct 138 ms 52876 KB Output is correct
133 Correct 148 ms 43768 KB Output is correct
134 Correct 367 ms 35312 KB Output is correct
135 Correct 387 ms 34948 KB Output is correct
136 Correct 373 ms 34896 KB Output is correct
137 Correct 204 ms 37200 KB Output is correct
138 Correct 207 ms 37388 KB Output is correct
139 Correct 193 ms 37200 KB Output is correct
140 Correct 201 ms 37304 KB Output is correct
141 Correct 222 ms 37172 KB Output is correct
142 Correct 195 ms 37240 KB Output is correct
143 Correct 43 ms 30108 KB Output is correct
144 Correct 616 ms 37244 KB Output is correct