답안 #823685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823685 2023-08-13T00:51:48 Z thimote75 Tourism (JOI23_tourism) C++14
59 / 100
5000 ms 69372 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 = 2e5;

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, max(-1, 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, max(-1, 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, max(-1, 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;
    VirtualTree vt = create(tree, R, l, r, mid);

    vector<Query*> left_q, right_q;
    vector<Query*> mid_q;
    vector<Point> points;
    for (int i = 0; i < vt.L.size(); i ++)
        points.push_back({ vt.R[i], { vt.L[i], vt.C[i] } });
    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);
        }
    }

    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:279:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  279 |     for (int i = 0; i < vt.L.size(); i ++)
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 2 ms 2388 KB Output is correct
5 Correct 2 ms 2388 KB Output is correct
6 Correct 2 ms 2388 KB Output is correct
7 Correct 2 ms 2388 KB Output is correct
8 Correct 2 ms 2516 KB Output is correct
9 Correct 3 ms 2516 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 2 ms 2516 KB Output is correct
13 Correct 2 ms 2516 KB Output is correct
14 Correct 1 ms 2516 KB Output is correct
15 Correct 3 ms 2516 KB Output is correct
16 Correct 3 ms 2516 KB Output is correct
17 Correct 2 ms 2516 KB Output is correct
18 Correct 3 ms 2516 KB Output is correct
19 Correct 3 ms 2516 KB Output is correct
20 Correct 3 ms 2516 KB Output is correct
21 Correct 3 ms 2516 KB Output is correct
22 Correct 3 ms 2516 KB Output is correct
23 Correct 4 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 3 ms 2516 KB Output is correct
26 Correct 3 ms 2548 KB Output is correct
27 Correct 1 ms 2388 KB Output is correct
28 Correct 2 ms 2388 KB Output is correct
29 Correct 4 ms 2516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 2 ms 2388 KB Output is correct
5 Correct 2 ms 2388 KB Output is correct
6 Correct 2 ms 2388 KB Output is correct
7 Correct 2 ms 2388 KB Output is correct
8 Correct 2 ms 2516 KB Output is correct
9 Correct 3 ms 2516 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 2 ms 2516 KB Output is correct
13 Correct 2 ms 2516 KB Output is correct
14 Correct 1 ms 2516 KB Output is correct
15 Correct 3 ms 2516 KB Output is correct
16 Correct 3 ms 2516 KB Output is correct
17 Correct 2 ms 2516 KB Output is correct
18 Correct 3 ms 2516 KB Output is correct
19 Correct 3 ms 2516 KB Output is correct
20 Correct 3 ms 2516 KB Output is correct
21 Correct 3 ms 2516 KB Output is correct
22 Correct 3 ms 2516 KB Output is correct
23 Correct 4 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 3 ms 2516 KB Output is correct
26 Correct 3 ms 2548 KB Output is correct
27 Correct 1 ms 2388 KB Output is correct
28 Correct 2 ms 2388 KB Output is correct
29 Correct 4 ms 2516 KB Output is correct
30 Correct 17 ms 3348 KB Output is correct
31 Correct 16 ms 3296 KB Output is correct
32 Correct 20 ms 3540 KB Output is correct
33 Correct 21 ms 3624 KB Output is correct
34 Correct 20 ms 3640 KB Output is correct
35 Correct 6 ms 3444 KB Output is correct
36 Correct 6 ms 3412 KB Output is correct
37 Correct 6 ms 3412 KB Output is correct
38 Correct 16 ms 3540 KB Output is correct
39 Correct 15 ms 3492 KB Output is correct
40 Correct 16 ms 3556 KB Output is correct
41 Correct 5 ms 3412 KB Output is correct
42 Correct 5 ms 3412 KB Output is correct
43 Correct 5 ms 3412 KB Output is correct
44 Correct 17 ms 3540 KB Output is correct
45 Correct 20 ms 3560 KB Output is correct
46 Correct 17 ms 3580 KB Output is correct
47 Correct 5 ms 3412 KB Output is correct
48 Correct 5 ms 3412 KB Output is correct
49 Correct 6 ms 3412 KB Output is correct
50 Correct 24 ms 3496 KB Output is correct
51 Correct 20 ms 3432 KB Output is correct
52 Correct 25 ms 3548 KB Output is correct
53 Correct 23 ms 3540 KB Output is correct
54 Correct 22 ms 3540 KB Output is correct
55 Correct 23 ms 3560 KB Output is correct
56 Correct 2 ms 2452 KB Output is correct
57 Correct 3 ms 3028 KB Output is correct
58 Correct 30 ms 3604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2272 KB Output is correct
3 Correct 2 ms 2516 KB Output is correct
4 Correct 883 ms 41960 KB Output is correct
5 Correct 652 ms 49128 KB Output is correct
6 Correct 944 ms 56540 KB Output is correct
7 Correct 1188 ms 66264 KB Output is correct
8 Correct 1183 ms 66232 KB Output is correct
9 Correct 1150 ms 66252 KB Output is correct
10 Correct 1207 ms 66252 KB Output is correct
11 Correct 1171 ms 66344 KB Output is correct
12 Correct 235 ms 62380 KB Output is correct
13 Correct 256 ms 62456 KB Output is correct
14 Correct 259 ms 62412 KB Output is correct
15 Correct 114 ms 45948 KB Output is correct
16 Correct 1792 ms 66956 KB Output is correct
17 Correct 80 ms 11100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1193 ms 32384 KB Output is correct
3 Correct 2025 ms 40228 KB Output is correct
4 Correct 1514 ms 40072 KB Output is correct
5 Correct 275 ms 53064 KB Output is correct
6 Correct 471 ms 57388 KB Output is correct
7 Correct 824 ms 58464 KB Output is correct
8 Correct 1172 ms 59028 KB Output is correct
9 Correct 1582 ms 58892 KB Output is correct
10 Correct 1880 ms 58924 KB Output is correct
11 Correct 2264 ms 58944 KB Output is correct
12 Correct 2642 ms 59236 KB Output is correct
13 Correct 2939 ms 59616 KB Output is correct
14 Correct 3103 ms 61412 KB Output is correct
15 Correct 3240 ms 67280 KB Output is correct
16 Correct 1968 ms 59956 KB Output is correct
17 Correct 2012 ms 59696 KB Output is correct
18 Correct 1999 ms 60012 KB Output is correct
19 Correct 298 ms 52420 KB Output is correct
20 Correct 344 ms 53884 KB Output is correct
21 Correct 545 ms 54620 KB Output is correct
22 Correct 678 ms 54648 KB Output is correct
23 Correct 841 ms 54676 KB Output is correct
24 Correct 1086 ms 54720 KB Output is correct
25 Correct 1294 ms 54696 KB Output is correct
26 Correct 1501 ms 54700 KB Output is correct
27 Correct 1755 ms 54748 KB Output is correct
28 Correct 1976 ms 54692 KB Output is correct
29 Correct 2234 ms 54764 KB Output is correct
30 Correct 2606 ms 55372 KB Output is correct
31 Correct 2730 ms 55592 KB Output is correct
32 Correct 2876 ms 56576 KB Output is correct
33 Correct 3015 ms 58908 KB Output is correct
34 Correct 3091 ms 63252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 3 ms 2516 KB Output is correct
4 Correct 1527 ms 45424 KB Output is correct
5 Correct 1555 ms 48712 KB Output is correct
6 Correct 1808 ms 62228 KB Output is correct
7 Correct 1870 ms 69372 KB Output is correct
8 Correct 1844 ms 69228 KB Output is correct
9 Correct 1930 ms 68984 KB Output is correct
10 Correct 1887 ms 69188 KB Output is correct
11 Correct 1860 ms 69072 KB Output is correct
12 Correct 1880 ms 69092 KB Output is correct
13 Correct 1897 ms 69244 KB Output is correct
14 Correct 83 ms 11072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 2 ms 2388 KB Output is correct
5 Correct 2 ms 2388 KB Output is correct
6 Correct 2 ms 2388 KB Output is correct
7 Correct 2 ms 2388 KB Output is correct
8 Correct 2 ms 2516 KB Output is correct
9 Correct 3 ms 2516 KB Output is correct
10 Correct 4 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 2 ms 2516 KB Output is correct
13 Correct 2 ms 2516 KB Output is correct
14 Correct 1 ms 2516 KB Output is correct
15 Correct 3 ms 2516 KB Output is correct
16 Correct 3 ms 2516 KB Output is correct
17 Correct 2 ms 2516 KB Output is correct
18 Correct 3 ms 2516 KB Output is correct
19 Correct 3 ms 2516 KB Output is correct
20 Correct 3 ms 2516 KB Output is correct
21 Correct 3 ms 2516 KB Output is correct
22 Correct 3 ms 2516 KB Output is correct
23 Correct 4 ms 2516 KB Output is correct
24 Correct 3 ms 2516 KB Output is correct
25 Correct 3 ms 2516 KB Output is correct
26 Correct 3 ms 2548 KB Output is correct
27 Correct 1 ms 2388 KB Output is correct
28 Correct 2 ms 2388 KB Output is correct
29 Correct 4 ms 2516 KB Output is correct
30 Correct 17 ms 3348 KB Output is correct
31 Correct 16 ms 3296 KB Output is correct
32 Correct 20 ms 3540 KB Output is correct
33 Correct 21 ms 3624 KB Output is correct
34 Correct 20 ms 3640 KB Output is correct
35 Correct 6 ms 3444 KB Output is correct
36 Correct 6 ms 3412 KB Output is correct
37 Correct 6 ms 3412 KB Output is correct
38 Correct 16 ms 3540 KB Output is correct
39 Correct 15 ms 3492 KB Output is correct
40 Correct 16 ms 3556 KB Output is correct
41 Correct 5 ms 3412 KB Output is correct
42 Correct 5 ms 3412 KB Output is correct
43 Correct 5 ms 3412 KB Output is correct
44 Correct 17 ms 3540 KB Output is correct
45 Correct 20 ms 3560 KB Output is correct
46 Correct 17 ms 3580 KB Output is correct
47 Correct 5 ms 3412 KB Output is correct
48 Correct 5 ms 3412 KB Output is correct
49 Correct 6 ms 3412 KB Output is correct
50 Correct 24 ms 3496 KB Output is correct
51 Correct 20 ms 3432 KB Output is correct
52 Correct 25 ms 3548 KB Output is correct
53 Correct 23 ms 3540 KB Output is correct
54 Correct 22 ms 3540 KB Output is correct
55 Correct 23 ms 3560 KB Output is correct
56 Correct 2 ms 2452 KB Output is correct
57 Correct 3 ms 3028 KB Output is correct
58 Correct 30 ms 3604 KB Output is correct
59 Correct 1 ms 2260 KB Output is correct
60 Correct 1 ms 2272 KB Output is correct
61 Correct 2 ms 2516 KB Output is correct
62 Correct 883 ms 41960 KB Output is correct
63 Correct 652 ms 49128 KB Output is correct
64 Correct 944 ms 56540 KB Output is correct
65 Correct 1188 ms 66264 KB Output is correct
66 Correct 1183 ms 66232 KB Output is correct
67 Correct 1150 ms 66252 KB Output is correct
68 Correct 1207 ms 66252 KB Output is correct
69 Correct 1171 ms 66344 KB Output is correct
70 Correct 235 ms 62380 KB Output is correct
71 Correct 256 ms 62456 KB Output is correct
72 Correct 259 ms 62412 KB Output is correct
73 Correct 114 ms 45948 KB Output is correct
74 Correct 1792 ms 66956 KB Output is correct
75 Correct 80 ms 11100 KB Output is correct
76 Correct 1 ms 2260 KB Output is correct
77 Correct 1193 ms 32384 KB Output is correct
78 Correct 2025 ms 40228 KB Output is correct
79 Correct 1514 ms 40072 KB Output is correct
80 Correct 275 ms 53064 KB Output is correct
81 Correct 471 ms 57388 KB Output is correct
82 Correct 824 ms 58464 KB Output is correct
83 Correct 1172 ms 59028 KB Output is correct
84 Correct 1582 ms 58892 KB Output is correct
85 Correct 1880 ms 58924 KB Output is correct
86 Correct 2264 ms 58944 KB Output is correct
87 Correct 2642 ms 59236 KB Output is correct
88 Correct 2939 ms 59616 KB Output is correct
89 Correct 3103 ms 61412 KB Output is correct
90 Correct 3240 ms 67280 KB Output is correct
91 Correct 1968 ms 59956 KB Output is correct
92 Correct 2012 ms 59696 KB Output is correct
93 Correct 1999 ms 60012 KB Output is correct
94 Correct 298 ms 52420 KB Output is correct
95 Correct 344 ms 53884 KB Output is correct
96 Correct 545 ms 54620 KB Output is correct
97 Correct 678 ms 54648 KB Output is correct
98 Correct 841 ms 54676 KB Output is correct
99 Correct 1086 ms 54720 KB Output is correct
100 Correct 1294 ms 54696 KB Output is correct
101 Correct 1501 ms 54700 KB Output is correct
102 Correct 1755 ms 54748 KB Output is correct
103 Correct 1976 ms 54692 KB Output is correct
104 Correct 2234 ms 54764 KB Output is correct
105 Correct 2606 ms 55372 KB Output is correct
106 Correct 2730 ms 55592 KB Output is correct
107 Correct 2876 ms 56576 KB Output is correct
108 Correct 3015 ms 58908 KB Output is correct
109 Correct 3091 ms 63252 KB Output is correct
110 Correct 1 ms 2260 KB Output is correct
111 Correct 1 ms 2388 KB Output is correct
112 Correct 3 ms 2516 KB Output is correct
113 Correct 1527 ms 45424 KB Output is correct
114 Correct 1555 ms 48712 KB Output is correct
115 Correct 1808 ms 62228 KB Output is correct
116 Correct 1870 ms 69372 KB Output is correct
117 Correct 1844 ms 69228 KB Output is correct
118 Correct 1930 ms 68984 KB Output is correct
119 Correct 1887 ms 69188 KB Output is correct
120 Correct 1860 ms 69072 KB Output is correct
121 Correct 1880 ms 69092 KB Output is correct
122 Correct 1897 ms 69244 KB Output is correct
123 Correct 83 ms 11072 KB Output is correct
124 Correct 1899 ms 62360 KB Output is correct
125 Correct 1375 ms 54628 KB Output is correct
126 Correct 2172 ms 66352 KB Output is correct
127 Correct 2178 ms 66372 KB Output is correct
128 Correct 2198 ms 66336 KB Output is correct
129 Correct 2138 ms 66432 KB Output is correct
130 Correct 2205 ms 66548 KB Output is correct
131 Correct 1575 ms 65524 KB Output is correct
132 Correct 1692 ms 66160 KB Output is correct
133 Correct 1625 ms 64156 KB Output is correct
134 Correct 1865 ms 62168 KB Output is correct
135 Correct 1969 ms 62108 KB Output is correct
136 Correct 1983 ms 62084 KB Output is correct
137 Execution timed out 5081 ms 62668 KB Time limit exceeded
138 Halted 0 ms 0 KB -