답안 #933968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933968 2024-02-26T15:46:35 Z boris_mihov Tourism (JOI23_tourism) C++17
100 / 100
3221 ms 43676 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <stack>
#include <cmath>

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

typedef long long llong;
const int MAXN = 100000 + 10;
const int MAXLOG = 18;
const int INF  = 1e9;

int n, m, q;
int in[MAXN];
int out[MAXN];
int globalCost;
bool isInC[MAXN];
std::vector <int> notInC;
std::vector <int> inTimes;
int cnt[2 * MAXN];
int c[MAXN];

struct LinkedList
{
    struct Sparse
    {
        int sparse[MAXLOG][2 * MAXN];
        std::vector <int> tour;
        int getLog[2 * MAXN];
        int depth[MAXN];

        int cmp(int x, int y)
        {
            if (depth[x] < depth[y]) return x;
            else return y;
        }

        void build(std::vector <int> _tour, int dep[])
        {
            tour = _tour;
            for (int i = 1 ; i <= n ; ++i)
            {
                depth[i] = dep[i];
            }

            for (int i = 1 ; i < tour.size() ; ++i)
            {
                sparse[0][i] = tour[i];
            }

            for (int lg = 1 ; (1 << lg) <= tour.size() ; ++lg)
            {
                for (int i = 1 ; i + (1 << lg) - 1 < tour.size() ; ++i)
                {
                    sparse[lg][i] = cmp(sparse[lg - 1][i], sparse[lg - 1][i + (1 << lg - 1)]);
                }
            }

            for (int i = 1 ; i <= tour.size() ; ++i)
            {
                getLog[i] = getLog[i - 1];
                if ((1 << getLog[i] + 1) < i) getLog[i]++;
            }
        }

        int findLCA(int l, int r)
        {
            int lg = getLog[r - l + 1];
            return cmp(sparse[lg][l], sparse[lg][r - (1 << lg) + 1]);
        }

        int findDist(int u, int v)
        {
            if (in[u] > in[v])
            {
                std::swap(u, v);
            }

            return depth[u] + depth[v] - 2 * depth[findLCA(in[u], in[v])];
        }
    };

    struct RollElementCnt
    {
        int idx;
        int time;
        int value;
    };

    
    struct RollElement
    {
        int idx;
        int value;
    };

    int answer;
    int prev[2 * MAXN];
    int next[2 * MAXN];
    int prev2[2 * MAXN];
    int next2[2 * MAXN];
    int answer2;

    std::stack <RollElement> stNext;
    std::stack <RollElement> stPrev;
    std::stack <RollElementCnt> stCnt;
    std::stack <int> stAnswer;
    std::stack <int> stTime;
    std::vector <int> tour;
    Sparse sparse;
    int timer;

    void build(std::vector <int> _tour, int depth[])
    {
        tour = _tour;
        sparse.build(tour, depth);
    }

    void fix()
    {
        int ptr = 0;
        for (int i = 0 ; i <= tour.size() ; ++i)
        {
            while (inTimes[ptr] <= i)
            {
                ptr++;
            }

            next[i] = inTimes[ptr];
        }

        ptr = inTimes.size() - 1;
        for (int i = tour.size() ; i >= 0 ; --i)
        {
            while (inTimes[ptr] >= i)
            {
                ptr--;
            }

            prev[i] = inTimes[ptr];
        }

        std::fill(cnt, cnt + 1 + 2 * n, 0);
        for (int i = 1 ; i <= m ; ++i)
        {
            cnt[in[c[i]]]++;
        }

        answer = 2 * n - 2 - sparse.findDist(tour[next[0]], tour[prev[tour.size()]]);
        timer = 0;

        for (const int &i : notInC)
        {
            remove(in[i]);
        }

        for (int i = 0 ; i <= tour.size() + 1 ; ++i)
        {
            prev2[i] = prev[i];
            next2[i] = next[i];
        }

        answer2 = answer;
    }

    void rebuild()
    {
        while (stNext.size())
        {
            stNext.pop();
        }

        while (stPrev.size())
        {
            stPrev.pop();
        }

        while (stCnt.size())
        {
            stCnt.pop();
        }

        while (stAnswer.size())
        {
            stAnswer.pop();
        }

        while (stTime.size())
        {
            stTime.pop();
        }

        std::fill(cnt, cnt + 1 + 2 * n, 0);
        for (int i = 1 ; i <= m ; ++i)
        {
            cnt[in[c[i]]]++;
        }

        timer = 0;
        for (int i = 0 ; i <= tour.size() + 1 ; ++i)
        {
            prev[i] = prev2[i];
            next[i] = next2[i];
        }

        answer = answer2;
    }

    void roll(int to)
    {
        while (stCnt.size() && stCnt.top().time > to)
        {
            cnt[stCnt.top().idx] = stCnt.top().value;
            stCnt.pop();
        }

        while (stTime.size() && stTime.top() > to)
        {
            next[stNext.top().idx] = stNext.top().value;
            prev[stPrev.top().idx] = stPrev.top().value;
            answer = stAnswer.top();
            stNext.pop();
            stTime.pop();
            stPrev.pop();
            stAnswer.pop();
        }
    }

    void remove(int idx)
    {
        timer++;
        stCnt.push({idx, timer, cnt[idx]});
        cnt[idx]--;

        if (cnt[idx] > 0)
        {
            return;
        }

        int l = prev[idx];
        int r = next[idx];
        stTime.push(timer);
        stAnswer.push(answer);
        stNext.push({l, next[l]});
        stPrev.push({r, prev[r]});

        if (l > 0) answer -= sparse.findDist(tour[l], tour[idx]);
        if (r < tour.size()) answer -= sparse.findDist(tour[idx], tour[r]);
        if (l > 0 && r < tour.size()) answer += sparse.findDist(tour[l], tour[r]);
        next[l] = r;
        prev[r] = l;
        getAnswer();
    }

    int getAnswer()
    {
        int res = answer;
        res += sparse.findDist(tour[next[0]], tour[prev[tour.size()]]);
        return res / 2 + 1;
    }
};

int bucketSize;
LinkedList list;
struct Query
{
    int l, r;
    int idx;

    friend bool operator < (const Query &a, const Query &b)
    {
        if (a.l / bucketSize != b.l / bucketSize) return a.l < b.l;
        return a.r > b.r;
    }
};

int depth[MAXN];
int answer[MAXN];
std::vector <int> tour;
std::vector <int> g[MAXN];
Query query[MAXN];

void buildDFS(int node, int par)
{
    depth[node] = depth[par] + 1;
    in[node] = tour.size();
    tour.push_back(node);

    for (const int &u : g[node])
    {
        if (u == par)
        {
            continue;
        }

        buildDFS(u, node);
        tour.push_back(node);
    }
    
    out[node] = tour.size();
}

void solve()
{
    bucketSize = 2 * sqrt(m) + 1;
    tour.push_back(0);
    buildDFS(1, 0);

    for (int i = 1 ; i <= n ; ++i)
    {
        inTimes.push_back(in[i]);
    }

    inTimes.push_back(-1);
    inTimes.push_back(0);
    inTimes.push_back(tour.size());
    inTimes.push_back(tour.size() + 1);
    std::sort(inTimes.begin(), inTimes.end());
    for (int i = 1 ; i <= m ; ++i)
    {
        isInC[c[i]] = true;
    }

    for (int i = 1 ; i <= n ; ++i)
    {
        if (!isInC[i])
        {
            notInC.push_back(i);
        }
    }

    list.build(tour, depth);
    list.fix();

    int lPtr = 1;
    int rPtr = m;
    int lastBucket = -1;
    std::sort(query + 1, query + 1 + q);
    for (int i = 1 ; i <= q ; ++i)
    {
        int qL = query[i].l;
        int qR = query[i].r;

        if (qL / bucketSize != lastBucket)
        {
            lPtr = 1;
            rPtr = m;
            list.rebuild();
            lastBucket = qL / bucketSize;
            while (lPtr / bucketSize != lastBucket)
            {
                list.remove(in[c[lPtr]]);
                lPtr++;
            }
        }

        while (rPtr > qR)
        {
            list.remove(in[c[rPtr]]);
            rPtr--;
        }

        int rollTo = list.timer;
        int beforeL = lPtr;

        while (lPtr < qL)
        {
            list.remove(in[c[lPtr]]);
            lPtr++;
        }

        answer[query[i].idx] = list.getAnswer();
        lPtr = beforeL;
        list.getAnswer();
        list.roll(rollTo);
        list.getAnswer();
    }
}

void input()
{
    std::cin >> n >> m >> q;
    for (int i = 1 ; i < n ; ++i)
    {
        int u, v;
        std::cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for (int i = 1 ; i <= m ; ++i)
    {
        std::cin >> c[i];
    }

    for (int i = 1 ; i <= q ; ++i)
    {
        std::cin >> query[i].l >> query[i].r;
        query[i].idx = i;
    }
}

void print()
{
    for (int i = 1 ; i <= q ; ++i)
    {
        std::cout << answer[i] << '\n';
    }
}

void fastIOI()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIOI();
    input();
    solve();
    print();
    
    return 0;
}

Compilation message

tourism.cpp: In member function 'void LinkedList::Sparse::build(std::vector<int>, int*)':
tourism.cpp:50:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             for (int i = 1 ; i < tour.size() ; ++i)
      |                              ~~^~~~~~~~~~~~~
tourism.cpp:55:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for (int lg = 1 ; (1 << lg) <= tour.size() ; ++lg)
      |                               ~~~~~~~~~~^~~~~~~~~~~~~~
tourism.cpp:57:52: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |                 for (int i = 1 ; i + (1 << lg) - 1 < tour.size() ; ++i)
      |                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
tourism.cpp:59:88: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   59 |                     sparse[lg][i] = cmp(sparse[lg - 1][i], sparse[lg - 1][i + (1 << lg - 1)]);
      |                                                                                     ~~~^~~
tourism.cpp:63:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             for (int i = 1 ; i <= tour.size() ; ++i)
      |                              ~~^~~~~~~~~~~~~~
tourism.cpp:66:37: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   66 |                 if ((1 << getLog[i] + 1) < i) getLog[i]++;
      |                           ~~~~~~~~~~^~~
tourism.cpp: In member function 'void LinkedList::fix()':
tourism.cpp:126:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |         for (int i = 0 ; i <= tour.size() ; ++i)
      |                          ~~^~~~~~~~~~~~~~
tourism.cpp:161:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  161 |         for (int i = 0 ; i <= tour.size() + 1 ; ++i)
      |                          ~~^~~~~~~~~~~~~~~~~~
tourism.cpp: In member function 'void LinkedList::rebuild()':
tourism.cpp:204:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  204 |         for (int i = 0 ; i <= tour.size() + 1 ; ++i)
      |                          ~~^~~~~~~~~~~~~~~~~~
tourism.cpp: In member function 'void LinkedList::remove(int)':
tourism.cpp:252:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  252 |         if (r < tour.size()) answer -= sparse.findDist(tour[idx], tour[r]);
      |             ~~^~~~~~~~~~~~~
tourism.cpp:253:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  253 |         if (l > 0 && r < tour.size()) answer += sparse.findDist(tour[l], tour[r]);
      |                      ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 3 ms 12632 KB Output is correct
3 Correct 2 ms 14824 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 3 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 3 ms 16732 KB Output is correct
13 Correct 3 ms 16732 KB Output is correct
14 Correct 3 ms 16880 KB Output is correct
15 Correct 3 ms 16732 KB Output is correct
16 Correct 3 ms 16732 KB Output is correct
17 Correct 3 ms 16732 KB Output is correct
18 Correct 3 ms 16728 KB Output is correct
19 Correct 3 ms 16828 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 3 ms 16732 KB Output is correct
22 Correct 3 ms 16880 KB Output is correct
23 Correct 3 ms 16732 KB Output is correct
24 Correct 3 ms 16732 KB Output is correct
25 Correct 3 ms 16876 KB Output is correct
26 Correct 3 ms 16876 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 3 ms 16872 KB Output is correct
29 Correct 3 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 3 ms 12632 KB Output is correct
3 Correct 2 ms 14824 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 3 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 3 ms 16732 KB Output is correct
13 Correct 3 ms 16732 KB Output is correct
14 Correct 3 ms 16880 KB Output is correct
15 Correct 3 ms 16732 KB Output is correct
16 Correct 3 ms 16732 KB Output is correct
17 Correct 3 ms 16732 KB Output is correct
18 Correct 3 ms 16728 KB Output is correct
19 Correct 3 ms 16828 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 3 ms 16732 KB Output is correct
22 Correct 3 ms 16880 KB Output is correct
23 Correct 3 ms 16732 KB Output is correct
24 Correct 3 ms 16732 KB Output is correct
25 Correct 3 ms 16876 KB Output is correct
26 Correct 3 ms 16876 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 3 ms 16872 KB Output is correct
29 Correct 3 ms 16732 KB Output is correct
30 Correct 6 ms 19168 KB Output is correct
31 Correct 7 ms 19288 KB Output is correct
32 Correct 8 ms 19188 KB Output is correct
33 Correct 9 ms 19040 KB Output is correct
34 Correct 9 ms 19036 KB Output is correct
35 Correct 5 ms 19036 KB Output is correct
36 Correct 5 ms 19196 KB Output is correct
37 Correct 5 ms 19032 KB Output is correct
38 Correct 8 ms 19188 KB Output is correct
39 Correct 12 ms 19292 KB Output is correct
40 Correct 12 ms 19284 KB Output is correct
41 Correct 5 ms 19292 KB Output is correct
42 Correct 6 ms 19292 KB Output is correct
43 Correct 5 ms 19036 KB Output is correct
44 Correct 8 ms 19276 KB Output is correct
45 Correct 12 ms 19032 KB Output is correct
46 Correct 10 ms 19292 KB Output is correct
47 Correct 7 ms 19036 KB Output is correct
48 Correct 5 ms 19036 KB Output is correct
49 Correct 5 ms 19016 KB Output is correct
50 Correct 8 ms 19036 KB Output is correct
51 Correct 10 ms 19036 KB Output is correct
52 Correct 8 ms 19036 KB Output is correct
53 Correct 9 ms 19036 KB Output is correct
54 Correct 9 ms 19244 KB Output is correct
55 Correct 8 ms 19248 KB Output is correct
56 Correct 4 ms 10588 KB Output is correct
57 Correct 4 ms 19036 KB Output is correct
58 Correct 10 ms 19032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 4 ms 10840 KB Output is correct
4 Correct 1463 ms 34992 KB Output is correct
5 Correct 1279 ms 38084 KB Output is correct
6 Correct 1477 ms 40624 KB Output is correct
7 Correct 2315 ms 42796 KB Output is correct
8 Correct 2425 ms 42908 KB Output is correct
9 Correct 2381 ms 42800 KB Output is correct
10 Correct 2329 ms 42800 KB Output is correct
11 Correct 2367 ms 42964 KB Output is correct
12 Correct 262 ms 41268 KB Output is correct
13 Correct 269 ms 41308 KB Output is correct
14 Correct 262 ms 41380 KB Output is correct
15 Correct 68 ms 42408 KB Output is correct
16 Correct 2715 ms 42216 KB Output is correct
17 Correct 377 ms 13912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 429 ms 29624 KB Output is correct
3 Correct 769 ms 30968 KB Output is correct
4 Correct 579 ms 31708 KB Output is correct
5 Correct 61 ms 33960 KB Output is correct
6 Correct 69 ms 34112 KB Output is correct
7 Correct 122 ms 34948 KB Output is correct
8 Correct 251 ms 35284 KB Output is correct
9 Correct 779 ms 35360 KB Output is correct
10 Correct 1146 ms 35384 KB Output is correct
11 Correct 1238 ms 35404 KB Output is correct
12 Correct 1328 ms 35432 KB Output is correct
13 Correct 1665 ms 35312 KB Output is correct
14 Correct 1974 ms 35816 KB Output is correct
15 Correct 3161 ms 36280 KB Output is correct
16 Correct 938 ms 36084 KB Output is correct
17 Correct 1000 ms 36080 KB Output is correct
18 Correct 1018 ms 35892 KB Output is correct
19 Correct 64 ms 34284 KB Output is correct
20 Correct 60 ms 34384 KB Output is correct
21 Correct 83 ms 34992 KB Output is correct
22 Correct 101 ms 35236 KB Output is correct
23 Correct 162 ms 35672 KB Output is correct
24 Correct 374 ms 35776 KB Output is correct
25 Correct 594 ms 35748 KB Output is correct
26 Correct 1194 ms 35856 KB Output is correct
27 Correct 993 ms 35856 KB Output is correct
28 Correct 1027 ms 35844 KB Output is correct
29 Correct 1092 ms 35900 KB Output is correct
30 Correct 1122 ms 36236 KB Output is correct
31 Correct 1318 ms 36336 KB Output is correct
32 Correct 1463 ms 36256 KB Output is correct
33 Correct 2050 ms 36516 KB Output is correct
34 Correct 3057 ms 37216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 10588 KB Output is correct
3 Correct 3 ms 10588 KB Output is correct
4 Correct 1828 ms 31976 KB Output is correct
5 Correct 1798 ms 32388 KB Output is correct
6 Correct 2515 ms 35144 KB Output is correct
7 Correct 2985 ms 36536 KB Output is correct
8 Correct 2801 ms 36536 KB Output is correct
9 Correct 2890 ms 36580 KB Output is correct
10 Correct 2836 ms 36520 KB Output is correct
11 Correct 2807 ms 37292 KB Output is correct
12 Correct 2987 ms 37292 KB Output is correct
13 Correct 2976 ms 37548 KB Output is correct
14 Correct 366 ms 13980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 3 ms 12632 KB Output is correct
3 Correct 2 ms 14824 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 3 ms 16732 KB Output is correct
8 Correct 3 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 3 ms 16732 KB Output is correct
13 Correct 3 ms 16732 KB Output is correct
14 Correct 3 ms 16880 KB Output is correct
15 Correct 3 ms 16732 KB Output is correct
16 Correct 3 ms 16732 KB Output is correct
17 Correct 3 ms 16732 KB Output is correct
18 Correct 3 ms 16728 KB Output is correct
19 Correct 3 ms 16828 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 3 ms 16732 KB Output is correct
22 Correct 3 ms 16880 KB Output is correct
23 Correct 3 ms 16732 KB Output is correct
24 Correct 3 ms 16732 KB Output is correct
25 Correct 3 ms 16876 KB Output is correct
26 Correct 3 ms 16876 KB Output is correct
27 Correct 2 ms 10588 KB Output is correct
28 Correct 3 ms 16872 KB Output is correct
29 Correct 3 ms 16732 KB Output is correct
30 Correct 6 ms 19168 KB Output is correct
31 Correct 7 ms 19288 KB Output is correct
32 Correct 8 ms 19188 KB Output is correct
33 Correct 9 ms 19040 KB Output is correct
34 Correct 9 ms 19036 KB Output is correct
35 Correct 5 ms 19036 KB Output is correct
36 Correct 5 ms 19196 KB Output is correct
37 Correct 5 ms 19032 KB Output is correct
38 Correct 8 ms 19188 KB Output is correct
39 Correct 12 ms 19292 KB Output is correct
40 Correct 12 ms 19284 KB Output is correct
41 Correct 5 ms 19292 KB Output is correct
42 Correct 6 ms 19292 KB Output is correct
43 Correct 5 ms 19036 KB Output is correct
44 Correct 8 ms 19276 KB Output is correct
45 Correct 12 ms 19032 KB Output is correct
46 Correct 10 ms 19292 KB Output is correct
47 Correct 7 ms 19036 KB Output is correct
48 Correct 5 ms 19036 KB Output is correct
49 Correct 5 ms 19016 KB Output is correct
50 Correct 8 ms 19036 KB Output is correct
51 Correct 10 ms 19036 KB Output is correct
52 Correct 8 ms 19036 KB Output is correct
53 Correct 9 ms 19036 KB Output is correct
54 Correct 9 ms 19244 KB Output is correct
55 Correct 8 ms 19248 KB Output is correct
56 Correct 4 ms 10588 KB Output is correct
57 Correct 4 ms 19036 KB Output is correct
58 Correct 10 ms 19032 KB Output is correct
59 Correct 2 ms 12636 KB Output is correct
60 Correct 2 ms 10588 KB Output is correct
61 Correct 4 ms 10840 KB Output is correct
62 Correct 1463 ms 34992 KB Output is correct
63 Correct 1279 ms 38084 KB Output is correct
64 Correct 1477 ms 40624 KB Output is correct
65 Correct 2315 ms 42796 KB Output is correct
66 Correct 2425 ms 42908 KB Output is correct
67 Correct 2381 ms 42800 KB Output is correct
68 Correct 2329 ms 42800 KB Output is correct
69 Correct 2367 ms 42964 KB Output is correct
70 Correct 262 ms 41268 KB Output is correct
71 Correct 269 ms 41308 KB Output is correct
72 Correct 262 ms 41380 KB Output is correct
73 Correct 68 ms 42408 KB Output is correct
74 Correct 2715 ms 42216 KB Output is correct
75 Correct 377 ms 13912 KB Output is correct
76 Correct 2 ms 12636 KB Output is correct
77 Correct 429 ms 29624 KB Output is correct
78 Correct 769 ms 30968 KB Output is correct
79 Correct 579 ms 31708 KB Output is correct
80 Correct 61 ms 33960 KB Output is correct
81 Correct 69 ms 34112 KB Output is correct
82 Correct 122 ms 34948 KB Output is correct
83 Correct 251 ms 35284 KB Output is correct
84 Correct 779 ms 35360 KB Output is correct
85 Correct 1146 ms 35384 KB Output is correct
86 Correct 1238 ms 35404 KB Output is correct
87 Correct 1328 ms 35432 KB Output is correct
88 Correct 1665 ms 35312 KB Output is correct
89 Correct 1974 ms 35816 KB Output is correct
90 Correct 3161 ms 36280 KB Output is correct
91 Correct 938 ms 36084 KB Output is correct
92 Correct 1000 ms 36080 KB Output is correct
93 Correct 1018 ms 35892 KB Output is correct
94 Correct 64 ms 34284 KB Output is correct
95 Correct 60 ms 34384 KB Output is correct
96 Correct 83 ms 34992 KB Output is correct
97 Correct 101 ms 35236 KB Output is correct
98 Correct 162 ms 35672 KB Output is correct
99 Correct 374 ms 35776 KB Output is correct
100 Correct 594 ms 35748 KB Output is correct
101 Correct 1194 ms 35856 KB Output is correct
102 Correct 993 ms 35856 KB Output is correct
103 Correct 1027 ms 35844 KB Output is correct
104 Correct 1092 ms 35900 KB Output is correct
105 Correct 1122 ms 36236 KB Output is correct
106 Correct 1318 ms 36336 KB Output is correct
107 Correct 1463 ms 36256 KB Output is correct
108 Correct 2050 ms 36516 KB Output is correct
109 Correct 3057 ms 37216 KB Output is correct
110 Correct 2 ms 12636 KB Output is correct
111 Correct 2 ms 10588 KB Output is correct
112 Correct 3 ms 10588 KB Output is correct
113 Correct 1828 ms 31976 KB Output is correct
114 Correct 1798 ms 32388 KB Output is correct
115 Correct 2515 ms 35144 KB Output is correct
116 Correct 2985 ms 36536 KB Output is correct
117 Correct 2801 ms 36536 KB Output is correct
118 Correct 2890 ms 36580 KB Output is correct
119 Correct 2836 ms 36520 KB Output is correct
120 Correct 2807 ms 37292 KB Output is correct
121 Correct 2987 ms 37292 KB Output is correct
122 Correct 2976 ms 37548 KB Output is correct
123 Correct 366 ms 13980 KB Output is correct
124 Correct 2692 ms 37172 KB Output is correct
125 Correct 1468 ms 35472 KB Output is correct
126 Correct 3039 ms 37772 KB Output is correct
127 Correct 3063 ms 37728 KB Output is correct
128 Correct 3150 ms 37716 KB Output is correct
129 Correct 3121 ms 37848 KB Output is correct
130 Correct 3068 ms 37724 KB Output is correct
131 Correct 2624 ms 42940 KB Output is correct
132 Correct 2627 ms 43676 KB Output is correct
133 Correct 2564 ms 40760 KB Output is correct
134 Correct 2755 ms 37780 KB Output is correct
135 Correct 2615 ms 37752 KB Output is correct
136 Correct 2633 ms 37740 KB Output is correct
137 Correct 2715 ms 38036 KB Output is correct
138 Correct 2631 ms 38032 KB Output is correct
139 Correct 2634 ms 38144 KB Output is correct
140 Correct 2742 ms 38020 KB Output is correct
141 Correct 2815 ms 38196 KB Output is correct
142 Correct 2914 ms 38028 KB Output is correct
143 Correct 87 ms 36516 KB Output is correct
144 Correct 3221 ms 37380 KB Output is correct