답안 #823686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823686 2023-08-13T00:56:34 Z thimote75 Tourism (JOI23_tourism) C++14
100 / 100
4580 ms 59636 KB
#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;
using iset  = set<int>;
using igrid = vector<idata>;

using t_road  = pair<int, int>;
using t_roads = vector<t_road>;
using t_graph = vector<t_roads>;

using di = pair<int, int>;
using vd = vector<di>;

const int MAXK = 20;

struct Tree {
    igrid roads;

    idata preordre, postordre, parents, depth;
    igrid eulertour;
    igrid parents_2k;

    void dfs (int node, int parent, int _depth, int &iOrdre) {
        preordre[node] = iOrdre ++;
        parents [node] = parent;
        depth   [node] = _depth;

        for (int next : roads[node]) if (next != parent) {
            eulertour[node].push_back(iOrdre ++);
            dfs(next, node, _depth + 1, iOrdre);
        }
        
        postordre[node] = iOrdre ++;
    }

    Tree (int N, igrid &roads) : roads(roads) {
        eulertour.resize(N);
        postordre.resize(N);
        preordre .resize(N);
        parents  .resize(N);
        depth    .resize(N);

        int iOrdre = 0;
        dfs (0, -1, 0, iOrdre);

        parents_2k.resize(N, idata(MAXK, -1));

        for (int i = 0; i < N; i ++) parents_2k[i][0] = parents[i];

        for (int k = 0; k + 1 < MAXK; k ++) {
            for (int i = 0; i < N; i ++) {
                if (parents_2k[i][k] == -1) continue ;

                parents_2k[i][k + 1] = parents_2k[parents_2k[i][k]][k];
            }
        }
    }

    int jump (int node, int k) {
        for (int i = 0; i < MAXK; i ++)
            if ((1 << i) & k)
                node = parents_2k[node][i];
        
        return node;
    }
    int lca (int a, int b) {
        if (depth[a] > depth[b]) swap(a, b);

        b = jump(b, depth[b] - depth[a]);
        if (a == b) return a;

        for (int i = MAXK - 1; i >= 0; i --) {
            if (parents_2k[a][i] == parents_2k[b][i]) continue ;

            a = parents_2k[a][i];
            b = parents_2k[b][i];
        }

        if (a == b) return a;
        return parents[a];
    }
};

struct VirtualTree {
    int size = 1;
    t_graph roads;
    map<int, int> id_to_vid;

    int get (int node) {
        return (*id_to_vid.find(node)).second;
    }

    idata L;
    idata R;
    idata C;

    pair<int, int> dfs (int node, int parent, int coming) {
        C[node] = coming;
        for (const auto road : roads[node]) if (road.first != parent) {
            const auto data = dfs(road.first, node, road.second);

            L[node] = max(L[node], data.first);
            R[node] = min(R[node], data.second);
        }

        return { L[node], R[node] };
    }

    VirtualTree (Tree &tree, iset virtual_set) {
        vd order_positions;
        for (int u : virtual_set) order_positions.push_back({ tree.preordre[u], u });

        sort(order_positions.begin(), order_positions.end());

        for (int i = 0; i + 1 < order_positions.size(); i ++){
            int u = order_positions[i    ].second;
            int v = order_positions[i + 1].second;

            int l = tree.lca(u, v);
            virtual_set.insert(l);
        }

        vd dist_computations;
        for (int u : virtual_set) {
            dist_computations.push_back({ tree.preordre [u], u }); 
            for (int h : tree.eulertour[u])
                dist_computations.push_back({ h, u });
            dist_computations.push_back({ tree.postordre[u], u }); 
        }

        sort(dist_computations.begin(), dist_computations.end());

        set<pair<int, int>> pot_roads;

        for (int i = 0; i + 1 < dist_computations.size(); i ++) {
            int u = dist_computations[i]    .second;
            int v = dist_computations[i + 1].second;

            if (u == v) continue ;
            pot_roads.insert({ min(u, v), max(u, v) });
        }

        int iNode = 0;
        for (int u : virtual_set)
            id_to_vid.insert({ u, iNode ++ });
        
        roads.resize(virtual_set.size());
        for (const auto &road : pot_roads) {
            int u = road.first; int v = road.second;
            int dist = abs(tree.depth[u] - tree.depth[v]);

            size += dist;

            u = get(u); v = get(v);
            roads[u].push_back({ v, dist });
            roads[v].push_back({ u, dist });
        }

        L.resize(virtual_set.size(), - 1e9);
        R.resize(virtual_set.size(),   1e9);
        C.resize(virtual_set.size());
    }
};

struct Query {
    int l, r;
    int answer;

    int order (int mid) {
        if (r < mid) return -1;
        if (l > mid) return 1;
        return 0;
    }
};

struct SegTree {
    vector<int> tree;

    int start, height, size;

    SegTree () = default;
    SegTree (int _size) {
        size   = _size;
        height = ceil(log2(size));
        start  = 1 << height;

        tree.resize(start << 1);
    }
    int _query (int node) {
        if (node == 0) return 0;

        return tree[node] + _query(node >> 1);
    }
    int query (int node) {
        return _query(node + start);
    }
    void add (int l, int r, int x) {
        l += start; r += start;

        while (l < r) {
            if ((l & 1) == 1) tree[l] += x;
            if ((r & 1) == 0) tree[r] += x;

            l = (l + 1) >> 1;
            r = (r - 1) >> 1;
        }

        if (l == r) tree[l] += x;
    }
};

const int MAXS = 1e5 + 10;

SegTree stree(MAXS);

using Point = pair<int, pair<int, int>>;

struct QueryManager {
    static void solve (vector<Query*> queries, vector<Point> points) {
        sort(points.begin(), points.end());

        vd queries_time;
        for (int i = 0; i < queries.size(); i ++)
            queries_time.push_back({ queries[i]->r, i });
        sort(queries_time.begin(), queries_time.end());

        for (int iOP = 0; iOP < points.size(); iOP ++)
            stree.add(0, points[iOP].second.first, points[iOP].second.second);
        
        int bonus = 0;
        int iOP = 0;
        for (int iQ = 0; iQ < queries.size(); iQ ++) {
            int time = queries_time[iQ].first;
            int quid = queries_time[iQ].second;

            while (iOP != points.size() && time >= points[iOP].first) {
                stree.add(0, points[iOP].second.first, - points[iOP].second.second);
                bonus += points[iOP].second.second;
                iOP ++;
            }

            queries[quid]->answer = bonus + stree.query(queries[quid]->l);
        }

        for (; iOP < points.size(); iOP ++)
            stree.add(0, points[iOP].second.first, - points[iOP].second.second);
    }
};

VirtualTree create (Tree &tree, idata &R, int left, int right, int mid) {
    iset values;
    for (int u = left; u <= right; u ++)
        values.insert(R[u]);
    
    VirtualTree vt (tree, values);

    for (int u = left; u <= mid; u ++)
        vt.L[vt.get(R[u])] = u;
    for (int u = right; u >= mid; u --)
        vt.R[vt.get(R[u])] = u;
    
    vt.dfs(vt.get(R[mid]), -1, 1);

    return vt;
}

void solve (Tree &tree, idata &R, int l, int r, vector<Query*> queries) { // [l; r]
    if (queries.size() == 0) return ;

    int mid = (l + r) >> 1;

    vector<Query*> left_q, right_q;
    vector<Query*> mid_q;

    for (Query* q : queries) {
        int o = q->order(mid);
        if (o == -1)  left_q.push_back(q);
        if (o ==  1) right_q.push_back(q);

        if (o == 0) {
            mid_q.push_back(q);
        }
    }

    if (mid_q.size() != 0) {
        VirtualTree vt = create(tree, R, l, r, mid);
        vector<Point> points;
        for (int i = 0; i < vt.L.size(); i ++)
            points.push_back({ vt.R[i], { vt.L[i], vt.C[i] } });
        QueryManager::solve(mid_q, points);
    }

    solve(tree, R, l, mid - 1, left_q);
    solve(tree, R, mid + 1, r, right_q);
}

int main () {
    int N, M, Q;
    cin >> N >> M >> Q;

    igrid roads(N);
    for (int i = 1; i < N; i ++) {
        int a, b;
        cin >> a >> b;
        a --; b --;

        roads[a].push_back(b);
        roads[b].push_back(a);
    }

    Tree tree(N, roads);

    idata R(M);
    for (int i = 0; i < M; i ++) {
        cin >> R[i];
        R[i] --;
    }

    vector<Query*> queries;
    
    for (int q = 0; q < Q; q ++) {
        int l, r;
        cin >> l >> r;
        l --; r --;

        Query* qu = new Query();
        qu->l = l; qu->r = r;
        queries.push_back(qu);
    }

    solve(tree, R, 0, M - 1, queries);

    for (Query* q : queries) {
        cout << q->answer << "\n";
        delete q;
    }
}

Compilation message

tourism.cpp: In constructor 'VirtualTree::VirtualTree(Tree&, iset)':
tourism.cpp:118:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |         for (int i = 0; i + 1 < order_positions.size(); i ++){
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tourism.cpp:138:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |         for (int i = 0; i + 1 < dist_computations.size(); i ++) {
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
tourism.cpp: In static member function 'static void QueryManager::solve(std::vector<Query*>, std::vector<std::pair<int, std::pair<int, int> > >)':
tourism.cpp:226:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Query*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  226 |         for (int i = 0; i < queries.size(); i ++)
      |                         ~~^~~~~~~~~~~~~~~~
tourism.cpp:230:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  230 |         for (int iOP = 0; iOP < points.size(); iOP ++)
      |                           ~~~~^~~~~~~~~~~~~~~
tourism.cpp:235:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Query*>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  235 |         for (int iQ = 0; iQ < queries.size(); iQ ++) {
      |                          ~~~^~~~~~~~~~~~~~~~
tourism.cpp:239:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  239 |             while (iOP != points.size() && time >= points[iOP].first) {
      |                    ~~~~^~~~~~~~~~~~~~~~
tourism.cpp:248:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  248 |         for (; iOP < points.size(); iOP ++)
      |                ~~~~^~~~~~~~~~~~~~~
tourism.cpp: In function 'void solve(Tree&, idata&, int, int, std::vector<Query*>)':
tourism.cpp:291:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  291 |         for (int i = 0; i < vt.L.size(); i ++)
      |                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 2 ms 1364 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 2 ms 1364 KB Output is correct
7 Correct 2 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 3 ms 1492 KB Output is correct
10 Correct 3 ms 1492 KB Output is correct
11 Correct 3 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 2 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1492 KB Output is correct
18 Correct 2 ms 1492 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 2 ms 1492 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1492 KB Output is correct
23 Correct 3 ms 1492 KB Output is correct
24 Correct 2 ms 1492 KB Output is correct
25 Correct 2 ms 1492 KB Output is correct
26 Correct 3 ms 1492 KB Output is correct
27 Correct 1 ms 1364 KB Output is correct
28 Correct 1 ms 1364 KB Output is correct
29 Correct 3 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 2 ms 1364 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 2 ms 1364 KB Output is correct
7 Correct 2 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 3 ms 1492 KB Output is correct
10 Correct 3 ms 1492 KB Output is correct
11 Correct 3 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 2 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1492 KB Output is correct
18 Correct 2 ms 1492 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 2 ms 1492 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1492 KB Output is correct
23 Correct 3 ms 1492 KB Output is correct
24 Correct 2 ms 1492 KB Output is correct
25 Correct 2 ms 1492 KB Output is correct
26 Correct 3 ms 1492 KB Output is correct
27 Correct 1 ms 1364 KB Output is correct
28 Correct 1 ms 1364 KB Output is correct
29 Correct 3 ms 1492 KB Output is correct
30 Correct 14 ms 2160 KB Output is correct
31 Correct 15 ms 2176 KB Output is correct
32 Correct 18 ms 2460 KB Output is correct
33 Correct 20 ms 2476 KB Output is correct
34 Correct 19 ms 2388 KB Output is correct
35 Correct 5 ms 2388 KB Output is correct
36 Correct 6 ms 2388 KB Output is correct
37 Correct 6 ms 2388 KB Output is correct
38 Correct 14 ms 2496 KB Output is correct
39 Correct 14 ms 2388 KB Output is correct
40 Correct 15 ms 2500 KB Output is correct
41 Correct 5 ms 2388 KB Output is correct
42 Correct 5 ms 2388 KB Output is correct
43 Correct 5 ms 2388 KB Output is correct
44 Correct 16 ms 2388 KB Output is correct
45 Correct 16 ms 2440 KB Output is correct
46 Correct 15 ms 2432 KB Output is correct
47 Correct 5 ms 2388 KB Output is correct
48 Correct 5 ms 2388 KB Output is correct
49 Correct 5 ms 2388 KB Output is correct
50 Correct 20 ms 2388 KB Output is correct
51 Correct 18 ms 2432 KB Output is correct
52 Correct 22 ms 2420 KB Output is correct
53 Correct 19 ms 2444 KB Output is correct
54 Correct 20 ms 2416 KB Output is correct
55 Correct 19 ms 2388 KB Output is correct
56 Correct 2 ms 1364 KB Output is correct
57 Correct 3 ms 2004 KB Output is correct
58 Correct 22 ms 2444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 2 ms 1364 KB Output is correct
4 Correct 877 ms 37564 KB Output is correct
5 Correct 630 ms 44408 KB Output is correct
6 Correct 938 ms 51676 KB Output is correct
7 Correct 1102 ms 59528 KB Output is correct
8 Correct 1114 ms 59636 KB Output is correct
9 Correct 1160 ms 59584 KB Output is correct
10 Correct 1127 ms 59488 KB Output is correct
11 Correct 1123 ms 59552 KB Output is correct
12 Correct 248 ms 59400 KB Output is correct
13 Correct 248 ms 59456 KB Output is correct
14 Correct 250 ms 59516 KB Output is correct
15 Correct 123 ms 43432 KB Output is correct
16 Correct 1325 ms 59448 KB Output is correct
17 Correct 83 ms 8664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1246 ms 28160 KB Output is correct
3 Correct 2005 ms 32696 KB Output is correct
4 Correct 1530 ms 34472 KB Output is correct
5 Correct 297 ms 50324 KB Output is correct
6 Correct 496 ms 50348 KB Output is correct
7 Correct 810 ms 50324 KB Output is correct
8 Correct 1182 ms 50448 KB Output is correct
9 Correct 1506 ms 50344 KB Output is correct
10 Correct 1915 ms 50248 KB Output is correct
11 Correct 2234 ms 50340 KB Output is correct
12 Correct 2534 ms 50516 KB Output is correct
13 Correct 2900 ms 50800 KB Output is correct
14 Correct 3084 ms 51984 KB Output is correct
15 Correct 3204 ms 55740 KB Output is correct
16 Correct 1823 ms 50848 KB Output is correct
17 Correct 1939 ms 50896 KB Output is correct
18 Correct 1873 ms 50748 KB Output is correct
19 Correct 288 ms 49604 KB Output is correct
20 Correct 352 ms 49640 KB Output is correct
21 Correct 527 ms 49644 KB Output is correct
22 Correct 706 ms 49552 KB Output is correct
23 Correct 846 ms 49648 KB Output is correct
24 Correct 1086 ms 49656 KB Output is correct
25 Correct 1268 ms 49588 KB Output is correct
26 Correct 1490 ms 49640 KB Output is correct
27 Correct 1790 ms 49664 KB Output is correct
28 Correct 2045 ms 49620 KB Output is correct
29 Correct 2248 ms 49672 KB Output is correct
30 Correct 2501 ms 49832 KB Output is correct
31 Correct 2679 ms 50108 KB Output is correct
32 Correct 2887 ms 50668 KB Output is correct
33 Correct 3004 ms 52316 KB Output is correct
34 Correct 3182 ms 55148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 2 ms 1364 KB Output is correct
4 Correct 1428 ms 36924 KB Output is correct
5 Correct 1475 ms 37832 KB Output is correct
6 Correct 1698 ms 50320 KB Output is correct
7 Correct 1850 ms 56996 KB Output is correct
8 Correct 1853 ms 57024 KB Output is correct
9 Correct 1938 ms 56880 KB Output is correct
10 Correct 1816 ms 57000 KB Output is correct
11 Correct 1801 ms 57024 KB Output is correct
12 Correct 1900 ms 57004 KB Output is correct
13 Correct 2184 ms 56952 KB Output is correct
14 Correct 79 ms 8716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 2 ms 1364 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 2 ms 1364 KB Output is correct
7 Correct 2 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 3 ms 1492 KB Output is correct
10 Correct 3 ms 1492 KB Output is correct
11 Correct 3 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 2 ms 1492 KB Output is correct
16 Correct 2 ms 1492 KB Output is correct
17 Correct 2 ms 1492 KB Output is correct
18 Correct 2 ms 1492 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 2 ms 1492 KB Output is correct
21 Correct 2 ms 1492 KB Output is correct
22 Correct 2 ms 1492 KB Output is correct
23 Correct 3 ms 1492 KB Output is correct
24 Correct 2 ms 1492 KB Output is correct
25 Correct 2 ms 1492 KB Output is correct
26 Correct 3 ms 1492 KB Output is correct
27 Correct 1 ms 1364 KB Output is correct
28 Correct 1 ms 1364 KB Output is correct
29 Correct 3 ms 1492 KB Output is correct
30 Correct 14 ms 2160 KB Output is correct
31 Correct 15 ms 2176 KB Output is correct
32 Correct 18 ms 2460 KB Output is correct
33 Correct 20 ms 2476 KB Output is correct
34 Correct 19 ms 2388 KB Output is correct
35 Correct 5 ms 2388 KB Output is correct
36 Correct 6 ms 2388 KB Output is correct
37 Correct 6 ms 2388 KB Output is correct
38 Correct 14 ms 2496 KB Output is correct
39 Correct 14 ms 2388 KB Output is correct
40 Correct 15 ms 2500 KB Output is correct
41 Correct 5 ms 2388 KB Output is correct
42 Correct 5 ms 2388 KB Output is correct
43 Correct 5 ms 2388 KB Output is correct
44 Correct 16 ms 2388 KB Output is correct
45 Correct 16 ms 2440 KB Output is correct
46 Correct 15 ms 2432 KB Output is correct
47 Correct 5 ms 2388 KB Output is correct
48 Correct 5 ms 2388 KB Output is correct
49 Correct 5 ms 2388 KB Output is correct
50 Correct 20 ms 2388 KB Output is correct
51 Correct 18 ms 2432 KB Output is correct
52 Correct 22 ms 2420 KB Output is correct
53 Correct 19 ms 2444 KB Output is correct
54 Correct 20 ms 2416 KB Output is correct
55 Correct 19 ms 2388 KB Output is correct
56 Correct 2 ms 1364 KB Output is correct
57 Correct 3 ms 2004 KB Output is correct
58 Correct 22 ms 2444 KB Output is correct
59 Correct 1 ms 1236 KB Output is correct
60 Correct 1 ms 1364 KB Output is correct
61 Correct 2 ms 1364 KB Output is correct
62 Correct 877 ms 37564 KB Output is correct
63 Correct 630 ms 44408 KB Output is correct
64 Correct 938 ms 51676 KB Output is correct
65 Correct 1102 ms 59528 KB Output is correct
66 Correct 1114 ms 59636 KB Output is correct
67 Correct 1160 ms 59584 KB Output is correct
68 Correct 1127 ms 59488 KB Output is correct
69 Correct 1123 ms 59552 KB Output is correct
70 Correct 248 ms 59400 KB Output is correct
71 Correct 248 ms 59456 KB Output is correct
72 Correct 250 ms 59516 KB Output is correct
73 Correct 123 ms 43432 KB Output is correct
74 Correct 1325 ms 59448 KB Output is correct
75 Correct 83 ms 8664 KB Output is correct
76 Correct 1 ms 1236 KB Output is correct
77 Correct 1246 ms 28160 KB Output is correct
78 Correct 2005 ms 32696 KB Output is correct
79 Correct 1530 ms 34472 KB Output is correct
80 Correct 297 ms 50324 KB Output is correct
81 Correct 496 ms 50348 KB Output is correct
82 Correct 810 ms 50324 KB Output is correct
83 Correct 1182 ms 50448 KB Output is correct
84 Correct 1506 ms 50344 KB Output is correct
85 Correct 1915 ms 50248 KB Output is correct
86 Correct 2234 ms 50340 KB Output is correct
87 Correct 2534 ms 50516 KB Output is correct
88 Correct 2900 ms 50800 KB Output is correct
89 Correct 3084 ms 51984 KB Output is correct
90 Correct 3204 ms 55740 KB Output is correct
91 Correct 1823 ms 50848 KB Output is correct
92 Correct 1939 ms 50896 KB Output is correct
93 Correct 1873 ms 50748 KB Output is correct
94 Correct 288 ms 49604 KB Output is correct
95 Correct 352 ms 49640 KB Output is correct
96 Correct 527 ms 49644 KB Output is correct
97 Correct 706 ms 49552 KB Output is correct
98 Correct 846 ms 49648 KB Output is correct
99 Correct 1086 ms 49656 KB Output is correct
100 Correct 1268 ms 49588 KB Output is correct
101 Correct 1490 ms 49640 KB Output is correct
102 Correct 1790 ms 49664 KB Output is correct
103 Correct 2045 ms 49620 KB Output is correct
104 Correct 2248 ms 49672 KB Output is correct
105 Correct 2501 ms 49832 KB Output is correct
106 Correct 2679 ms 50108 KB Output is correct
107 Correct 2887 ms 50668 KB Output is correct
108 Correct 3004 ms 52316 KB Output is correct
109 Correct 3182 ms 55148 KB Output is correct
110 Correct 1 ms 1236 KB Output is correct
111 Correct 1 ms 1364 KB Output is correct
112 Correct 2 ms 1364 KB Output is correct
113 Correct 1428 ms 36924 KB Output is correct
114 Correct 1475 ms 37832 KB Output is correct
115 Correct 1698 ms 50320 KB Output is correct
116 Correct 1850 ms 56996 KB Output is correct
117 Correct 1853 ms 57024 KB Output is correct
118 Correct 1938 ms 56880 KB Output is correct
119 Correct 1816 ms 57000 KB Output is correct
120 Correct 1801 ms 57024 KB Output is correct
121 Correct 1900 ms 57004 KB Output is correct
122 Correct 2184 ms 56952 KB Output is correct
123 Correct 79 ms 8716 KB Output is correct
124 Correct 2070 ms 53896 KB Output is correct
125 Correct 1316 ms 47920 KB Output is correct
126 Correct 2227 ms 55876 KB Output is correct
127 Correct 2074 ms 55868 KB Output is correct
128 Correct 2140 ms 56004 KB Output is correct
129 Correct 2188 ms 55748 KB Output is correct
130 Correct 2154 ms 55820 KB Output is correct
131 Correct 1649 ms 58812 KB Output is correct
132 Correct 1603 ms 59412 KB Output is correct
133 Correct 1605 ms 57280 KB Output is correct
134 Correct 1815 ms 55172 KB Output is correct
135 Correct 1842 ms 55248 KB Output is correct
136 Correct 1794 ms 55172 KB Output is correct
137 Correct 4384 ms 53888 KB Output is correct
138 Correct 4580 ms 56732 KB Output is correct
139 Correct 4527 ms 56800 KB Output is correct
140 Correct 4489 ms 56716 KB Output is correct
141 Correct 4580 ms 56772 KB Output is correct
142 Correct 4405 ms 56868 KB Output is correct
143 Correct 135 ms 39008 KB Output is correct
144 Correct 2188 ms 58748 KB Output is correct