Submission #986499

# Submission time Handle Problem Language Result Execution time Memory
986499 2024-05-20T16:46:24 Z boris_mihov JOI tour (JOI24_joitour) C++17
100 / 100
2476 ms 243760 KB
#include "joitour.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 200000 + 10;
const int MAXLOG = 20;
const llong INF = 1e18;
const int INTINF = 1e9;

int n, q;
struct Fenwick
{
    int tree[MAXN * MAXLOG];
    void update(int pos, int val)
    {
        assert(pos != 0);
        for (int idx = pos ; idx < MAXN * MAXLOG ; idx += idx & (-idx))
        {
            tree[idx] += val;
        }
    }

    int query(int pos)
    {
        int res = 0;
        for (int idx = pos ; idx > 0 ; idx -= idx & (-idx))
        {
            res += tree[idx];
        }

        return res;
    }

    int rangeQuery(int l, int r)
    {
        return query(r) - query(l - 1);
    }

    void rangeUpdate(int l, int r, int val)
    {
        update(l, val);
        update(r + 1, -val);
    }
};

int f[MAXN];
int sz[MAXN];
bool vis[MAXN];
int dep[MAXN];
int in[MAXN][MAXLOG];
int out[MAXN][MAXLOG];
int parC[MAXN][MAXLOG];
int centroid[MAXN][MAXLOG];

llong centroidAnswer[MAXN];
llong global10[MAXN];
llong global12[MAXN];
llong local10[MAXN][MAXLOG];
llong local12[MAXN][MAXLOG];
int global0[MAXN];
int global2[MAXN];
int local0[MAXN][MAXLOG];
int local2[MAXN][MAXLOG];
llong localSum02[MAXN];

std::vector <int> g[MAXN];
std::vector <int> c[MAXN];
Fenwick fenwick[3];
llong answer;

void findSize(int node, int par)
{
    sz[node] = 1;
    for (const int &u : g[node])
    {
        if (u == par || vis[u])
        {
            continue;
        }

        findSize(u, node);
        sz[node] += sz[u];
    }
}

int findCentroid(int node, int par, int globalSZ)
{
    sz[node] = 1;
    for (const int &u : g[node])
    {
        if (u == par || vis[u])
        {
            continue;
        }

        if (sz[u] > globalSZ / 2)
        {
            return findCentroid(u, node, globalSZ);
        }
    }

    return node;
}

int decompose(int node, int d)
{
    findSize(node, 0);
    int cntr = findCentroid(node, 0, sz[node]);
    dep[cntr] = d;
    vis[cntr] = true;

    for (const int &u : g[cntr])
    {
        if (vis[u])
        {
            continue;
        }

        c[cntr].push_back(decompose(u, d + 1));
    }

    return cntr;
}

void removeSubtreeAnswer(int node, int d)
{
    int cntr = centroid[node][d];
    answer -= centroidAnswer[cntr];
    centroidAnswer[cntr] -= (global10[cntr] - local10[node][d]) * local2[node][d]; 
    centroidAnswer[cntr] -= (global12[cntr] - local12[node][d]) * local0[node][d]; 
    centroidAnswer[cntr] -= (global2[cntr] - local2[node][d]) * local10[node][d]; 
    centroidAnswer[cntr] -= (global0[cntr] - local0[node][d]) * local12[node][d]; 
    answer += centroidAnswer[cntr];
    
    global10[cntr] -= local10[node][d];
    global12[cntr] -= local12[node][d];
    global0[cntr] -= local0[node][d];
    global2[cntr] -= local2[node][d];
    localSum02[cntr] -= 1LL * local0[node][d] * local2[node][d];
}

void addSubtreeAnswer(int node, int d)
{
    int cntr = centroid[node][d];
    global10[cntr] += local10[node][d];
    global12[cntr] += local12[node][d];
    global0[cntr] += local0[node][d];
    global2[cntr] += local2[node][d];
    localSum02[cntr] += 1LL * local0[node][d] * local2[node][d];
 
    answer -= centroidAnswer[cntr];
    centroidAnswer[cntr] += (global10[cntr] - local10[node][d]) * local2[node][d]; 
    centroidAnswer[cntr] += (global12[cntr] - local12[node][d]) * local0[node][d]; 
    centroidAnswer[cntr] += (global2[cntr] - local2[node][d]) * local10[node][d]; 
    centroidAnswer[cntr] += (global0[cntr] - local0[node][d]) * local12[node][d]; 
    answer += centroidAnswer[cntr];
}

void removeCentroidAnswer(int cntr)
{
    answer -= centroidAnswer[cntr];
    if (f[cntr] == 0)
    {
        centroidAnswer[cntr] -= global12[cntr];
    } else if (f[cntr] == 1)
    {
        centroidAnswer[cntr] -= 1LL * global0[cntr] * global2[cntr] - localSum02[cntr];
    } else
    {
        centroidAnswer[cntr] -= global10[cntr];
    }
 
    answer += centroidAnswer[cntr];
}

void addCentroidAnswer(int cntr)
{
    answer -= centroidAnswer[cntr];
    if (f[cntr] == 0)
    {
        centroidAnswer[cntr] += global12[cntr];
    } else if (f[cntr] == 1)
    {
        centroidAnswer[cntr] += 1LL * global0[cntr] * global2[cntr] - localSum02[cntr];
    } else
    {
        centroidAnswer[cntr] += global10[cntr];
    }
 
    answer += centroidAnswer[cntr];
}

void removeNodeAnswer(int node, int d)
{
    if (f[node] == 0)
    {
        local0[parC[node][d]][d]--;
        local10[parC[node][d]][d] -= fenwick[1].query(in[node][d]);
        fenwick[0].update(in[node][d], -1);
    } else if (f[node] == 1)
    {
        local10[parC[node][d]][d] -= fenwick[0].rangeQuery(in[node][d], out[node][d]);
        local12[parC[node][d]][d] -= fenwick[2].rangeQuery(in[node][d], out[node][d]);
        fenwick[1].rangeUpdate(in[node][d], out[node][d], -1);
    } else 
    {
        local2[parC[node][d]][d]--;
        local12[parC[node][d]][d] -= fenwick[1].query(in[node][d]);
        fenwick[2].update(in[node][d], -1);
    }
}

void addNodeAnswer(int node, int d)
{
    if (f[node] == 0)
    {
        local0[parC[node][d]][d]++;
        local10[parC[node][d]][d] += fenwick[1].query(in[node][d]);
        fenwick[0].update(in[node][d], 1);
    } else if (f[node] == 1)
    {
        local10[parC[node][d]][d] += fenwick[0].rangeQuery(in[node][d], out[node][d]);
        local12[parC[node][d]][d] += fenwick[2].rangeQuery(in[node][d], out[node][d]);
        fenwick[1].rangeUpdate(in[node][d], out[node][d], 1);
    } else 
    {
        local2[parC[node][d]][d]++;
        local12[parC[node][d]][d] += fenwick[1].query(in[node][d]);
        fenwick[2].update(in[node][d], 1);
    }
}

void updateNode(int node, int d, int from, int to)
{
    if (centroid[node][d] == node)
    {
        removeCentroidAnswer(node);
        f[node] = to;
        addCentroidAnswer(node);
        f[node] = from;
    } else
    {
        removeCentroidAnswer(centroid[node][d]);
        removeSubtreeAnswer(parC[node][d], d);
        removeNodeAnswer(node, d);

        f[node] = to;
        addNodeAnswer(node, d);
        addSubtreeAnswer(parC[node][d], d);
        addCentroidAnswer(centroid[node][d]);
        f[node] = from;
    }
}

void addNode(int node, int d)
{
    if (centroid[node][d] == node)
    {
        addCentroidAnswer(node);
    } else
    {
        removeCentroidAnswer(centroid[node][d]);
        removeSubtreeAnswer(parC[node][d], d);
        addNodeAnswer(node, d);
        addSubtreeAnswer(parC[node][d], d);
        addCentroidAnswer(centroid[node][d]);
    }
}

void callUpdate(int node, int d, int from, int to)
{
    updateNode(node, d, from, to);
    if (d > 1)
    {
        callUpdate(node, d - 1, from, to);
    }
}

int timer;
void buildDFS(int node, int par, int d, int parentC, int cntr)
{
    in[node][d] = ++timer;
    parC[node][d] = parentC;
    centroid[node][d] = cntr;

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

        buildDFS(u, node, d, (parentC == 0 ? u : parentC), cntr);
    }

    out[node][d] = timer;
}

void addDFS(int node, int par, int d)
{
    addNode(node, d);
    for (const int &u : g[node])
    {
        if (u == par || dep[u] <= d)
        {
            continue;
        }

        addDFS(u, node, d);
    }
}

void buildTour(int node)
{
    for (const int &u : c[node])
    {
        buildTour(u);
    }

    buildDFS(node, 0, dep[node], 0, node);
    addDFS(node, 0, dep[node]);
}

void init(int N, std::vector <int> F, std::vector <int> U, std::vector <int> V, int Q) 
{
    n = N; q = Q;
    for (int i = 0 ; i < n ; ++i)
    {
        f[i + 1] = F[i];
    }

    for (int i = 0 ; i < n - 1 ; ++i)
    {
        g[U[i] + 1].push_back(V[i] + 1);
        g[V[i] + 1].push_back(U[i] + 1);
    }

    int root = decompose(1, 1);
    buildTour(root);
}

void change(int node, int to)
{
    node++;
    callUpdate(node, dep[node], f[node], to);
    f[node] = to;
}

long long num_tours() 
{
    return answer;
}

/*
7
0 0 2 2 0 1 0
0 1
0 2
1 3
1 4
2 5
2 6
1
1 1
*/
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 4 ms 10072 KB Output is correct
3 Correct 4 ms 10072 KB Output is correct
4 Correct 5 ms 10328 KB Output is correct
5 Correct 5 ms 10072 KB Output is correct
6 Correct 5 ms 10072 KB Output is correct
7 Correct 5 ms 10092 KB Output is correct
8 Correct 5 ms 10072 KB Output is correct
9 Correct 6 ms 10328 KB Output is correct
10 Correct 5 ms 10328 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 4 ms 10072 KB Output is correct
13 Correct 4 ms 10072 KB Output is correct
14 Correct 4 ms 10072 KB Output is correct
15 Correct 6 ms 10072 KB Output is correct
16 Correct 5 ms 10072 KB Output is correct
17 Correct 4 ms 10072 KB Output is correct
18 Correct 5 ms 10072 KB Output is correct
19 Correct 5 ms 10328 KB Output is correct
20 Correct 4 ms 10072 KB Output is correct
21 Correct 4 ms 10072 KB Output is correct
22 Correct 4 ms 10072 KB Output is correct
23 Correct 5 ms 10072 KB Output is correct
24 Correct 6 ms 10328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 4 ms 10072 KB Output is correct
3 Correct 4 ms 10072 KB Output is correct
4 Correct 5 ms 10328 KB Output is correct
5 Correct 5 ms 10072 KB Output is correct
6 Correct 5 ms 10072 KB Output is correct
7 Correct 5 ms 10092 KB Output is correct
8 Correct 5 ms 10072 KB Output is correct
9 Correct 6 ms 10328 KB Output is correct
10 Correct 5 ms 10328 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 4 ms 10072 KB Output is correct
13 Correct 4 ms 10072 KB Output is correct
14 Correct 4 ms 10072 KB Output is correct
15 Correct 6 ms 10072 KB Output is correct
16 Correct 5 ms 10072 KB Output is correct
17 Correct 4 ms 10072 KB Output is correct
18 Correct 5 ms 10072 KB Output is correct
19 Correct 5 ms 10328 KB Output is correct
20 Correct 4 ms 10072 KB Output is correct
21 Correct 4 ms 10072 KB Output is correct
22 Correct 4 ms 10072 KB Output is correct
23 Correct 5 ms 10072 KB Output is correct
24 Correct 6 ms 10328 KB Output is correct
25 Correct 24 ms 14168 KB Output is correct
26 Correct 21 ms 14168 KB Output is correct
27 Correct 11 ms 13400 KB Output is correct
28 Correct 21 ms 14424 KB Output is correct
29 Correct 18 ms 13912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 1520 ms 236228 KB Output is correct
3 Correct 1488 ms 235700 KB Output is correct
4 Correct 1380 ms 233840 KB Output is correct
5 Correct 1585 ms 236616 KB Output is correct
6 Correct 450 ms 226588 KB Output is correct
7 Correct 450 ms 226664 KB Output is correct
8 Correct 1220 ms 227248 KB Output is correct
9 Correct 1374 ms 226752 KB Output is correct
10 Correct 1278 ms 224500 KB Output is correct
11 Correct 1240 ms 223804 KB Output is correct
12 Correct 1465 ms 231444 KB Output is correct
13 Correct 1441 ms 231304 KB Output is correct
14 Correct 1268 ms 231352 KB Output is correct
15 Correct 1391 ms 230660 KB Output is correct
16 Correct 1644 ms 240908 KB Output is correct
17 Correct 4 ms 9816 KB Output is correct
18 Correct 4 ms 10072 KB Output is correct
19 Correct 4 ms 10072 KB Output is correct
20 Correct 4 ms 10072 KB Output is correct
21 Correct 1110 ms 220060 KB Output is correct
22 Correct 1212 ms 219912 KB Output is correct
23 Correct 1098 ms 220420 KB Output is correct
24 Correct 1252 ms 220472 KB Output is correct
25 Correct 261 ms 185480 KB Output is correct
26 Correct 280 ms 182176 KB Output is correct
27 Correct 268 ms 185876 KB Output is correct
28 Correct 279 ms 182412 KB Output is correct
29 Correct 512 ms 243760 KB Output is correct
30 Correct 507 ms 243100 KB Output is correct
31 Correct 482 ms 243416 KB Output is correct
32 Correct 522 ms 243224 KB Output is correct
33 Correct 552 ms 224748 KB Output is correct
34 Correct 515 ms 223060 KB Output is correct
35 Correct 463 ms 224672 KB Output is correct
36 Correct 567 ms 223240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 5 ms 10064 KB Output is correct
3 Correct 6 ms 10072 KB Output is correct
4 Correct 7 ms 10072 KB Output is correct
5 Correct 6 ms 10276 KB Output is correct
6 Correct 7 ms 10080 KB Output is correct
7 Correct 6 ms 10328 KB Output is correct
8 Correct 22 ms 14424 KB Output is correct
9 Correct 544 ms 243392 KB Output is correct
10 Correct 524 ms 243168 KB Output is correct
11 Correct 484 ms 243392 KB Output is correct
12 Correct 528 ms 243052 KB Output is correct
13 Correct 417 ms 125620 KB Output is correct
14 Correct 443 ms 125628 KB Output is correct
15 Correct 599 ms 125540 KB Output is correct
16 Correct 606 ms 125436 KB Output is correct
17 Correct 525 ms 125472 KB Output is correct
18 Correct 620 ms 125320 KB Output is correct
19 Correct 890 ms 243488 KB Output is correct
20 Correct 971 ms 243368 KB Output is correct
21 Correct 1260 ms 243544 KB Output is correct
22 Correct 1350 ms 243100 KB Output is correct
23 Correct 1164 ms 243440 KB Output is correct
24 Correct 1446 ms 243196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10072 KB Output is correct
2 Correct 6 ms 9928 KB Output is correct
3 Correct 7 ms 10072 KB Output is correct
4 Correct 5 ms 10072 KB Output is correct
5 Correct 7 ms 10072 KB Output is correct
6 Correct 6 ms 10328 KB Output is correct
7 Correct 19 ms 13912 KB Output is correct
8 Correct 596 ms 224808 KB Output is correct
9 Correct 582 ms 223040 KB Output is correct
10 Correct 529 ms 224744 KB Output is correct
11 Correct 546 ms 223144 KB Output is correct
12 Correct 475 ms 116288 KB Output is correct
13 Correct 626 ms 116184 KB Output is correct
14 Correct 618 ms 116224 KB Output is correct
15 Correct 649 ms 115776 KB Output is correct
16 Correct 523 ms 116292 KB Output is correct
17 Correct 604 ms 115544 KB Output is correct
18 Correct 974 ms 224788 KB Output is correct
19 Correct 1340 ms 224784 KB Output is correct
20 Correct 1375 ms 224740 KB Output is correct
21 Correct 1412 ms 223144 KB Output is correct
22 Correct 1183 ms 224876 KB Output is correct
23 Correct 1405 ms 223040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 4 ms 10072 KB Output is correct
3 Correct 4 ms 10072 KB Output is correct
4 Correct 5 ms 10328 KB Output is correct
5 Correct 5 ms 10072 KB Output is correct
6 Correct 5 ms 10072 KB Output is correct
7 Correct 5 ms 10092 KB Output is correct
8 Correct 5 ms 10072 KB Output is correct
9 Correct 6 ms 10328 KB Output is correct
10 Correct 5 ms 10328 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 4 ms 10072 KB Output is correct
13 Correct 4 ms 10072 KB Output is correct
14 Correct 4 ms 10072 KB Output is correct
15 Correct 6 ms 10072 KB Output is correct
16 Correct 5 ms 10072 KB Output is correct
17 Correct 4 ms 10072 KB Output is correct
18 Correct 5 ms 10072 KB Output is correct
19 Correct 5 ms 10328 KB Output is correct
20 Correct 4 ms 10072 KB Output is correct
21 Correct 4 ms 10072 KB Output is correct
22 Correct 4 ms 10072 KB Output is correct
23 Correct 5 ms 10072 KB Output is correct
24 Correct 6 ms 10328 KB Output is correct
25 Correct 24 ms 14168 KB Output is correct
26 Correct 21 ms 14168 KB Output is correct
27 Correct 11 ms 13400 KB Output is correct
28 Correct 21 ms 14424 KB Output is correct
29 Correct 18 ms 13912 KB Output is correct
30 Correct 877 ms 120684 KB Output is correct
31 Correct 952 ms 121296 KB Output is correct
32 Correct 981 ms 121264 KB Output is correct
33 Correct 1139 ms 122008 KB Output is correct
34 Correct 1010 ms 122240 KB Output is correct
35 Correct 1081 ms 120932 KB Output is correct
36 Correct 592 ms 117144 KB Output is correct
37 Correct 534 ms 117224 KB Output is correct
38 Correct 1155 ms 117628 KB Output is correct
39 Correct 931 ms 117072 KB Output is correct
40 Correct 931 ms 116224 KB Output is correct
41 Correct 872 ms 115728 KB Output is correct
42 Correct 967 ms 119400 KB Output is correct
43 Correct 983 ms 119032 KB Output is correct
44 Correct 975 ms 119152 KB Output is correct
45 Correct 994 ms 119476 KB Output is correct
46 Correct 911 ms 118920 KB Output is correct
47 Correct 1000 ms 119564 KB Output is correct
48 Correct 983 ms 123132 KB Output is correct
49 Correct 922 ms 124060 KB Output is correct
50 Correct 1014 ms 123232 KB Output is correct
51 Correct 692 ms 114340 KB Output is correct
52 Correct 747 ms 114484 KB Output is correct
53 Correct 814 ms 114468 KB Output is correct
54 Correct 739 ms 114748 KB Output is correct
55 Correct 835 ms 114804 KB Output is correct
56 Correct 795 ms 114544 KB Output is correct
57 Correct 287 ms 97988 KB Output is correct
58 Correct 280 ms 97788 KB Output is correct
59 Correct 276 ms 97068 KB Output is correct
60 Correct 283 ms 97984 KB Output is correct
61 Correct 315 ms 96836 KB Output is correct
62 Correct 425 ms 125688 KB Output is correct
63 Correct 456 ms 125700 KB Output is correct
64 Correct 569 ms 125576 KB Output is correct
65 Correct 650 ms 125416 KB Output is correct
66 Correct 528 ms 125452 KB Output is correct
67 Correct 599 ms 125560 KB Output is correct
68 Correct 435 ms 116240 KB Output is correct
69 Correct 589 ms 116228 KB Output is correct
70 Correct 528 ms 116240 KB Output is correct
71 Correct 566 ms 115536 KB Output is correct
72 Correct 490 ms 116372 KB Output is correct
73 Correct 603 ms 115724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 10072 KB Output is correct
2 Correct 4 ms 10072 KB Output is correct
3 Correct 4 ms 10072 KB Output is correct
4 Correct 5 ms 10328 KB Output is correct
5 Correct 5 ms 10072 KB Output is correct
6 Correct 5 ms 10072 KB Output is correct
7 Correct 5 ms 10092 KB Output is correct
8 Correct 5 ms 10072 KB Output is correct
9 Correct 6 ms 10328 KB Output is correct
10 Correct 5 ms 10328 KB Output is correct
11 Correct 5 ms 9816 KB Output is correct
12 Correct 4 ms 10072 KB Output is correct
13 Correct 4 ms 10072 KB Output is correct
14 Correct 4 ms 10072 KB Output is correct
15 Correct 6 ms 10072 KB Output is correct
16 Correct 5 ms 10072 KB Output is correct
17 Correct 4 ms 10072 KB Output is correct
18 Correct 5 ms 10072 KB Output is correct
19 Correct 5 ms 10328 KB Output is correct
20 Correct 4 ms 10072 KB Output is correct
21 Correct 4 ms 10072 KB Output is correct
22 Correct 4 ms 10072 KB Output is correct
23 Correct 5 ms 10072 KB Output is correct
24 Correct 6 ms 10328 KB Output is correct
25 Correct 24 ms 14168 KB Output is correct
26 Correct 21 ms 14168 KB Output is correct
27 Correct 11 ms 13400 KB Output is correct
28 Correct 21 ms 14424 KB Output is correct
29 Correct 18 ms 13912 KB Output is correct
30 Correct 4 ms 10072 KB Output is correct
31 Correct 1520 ms 236228 KB Output is correct
32 Correct 1488 ms 235700 KB Output is correct
33 Correct 1380 ms 233840 KB Output is correct
34 Correct 1585 ms 236616 KB Output is correct
35 Correct 450 ms 226588 KB Output is correct
36 Correct 450 ms 226664 KB Output is correct
37 Correct 1220 ms 227248 KB Output is correct
38 Correct 1374 ms 226752 KB Output is correct
39 Correct 1278 ms 224500 KB Output is correct
40 Correct 1240 ms 223804 KB Output is correct
41 Correct 1465 ms 231444 KB Output is correct
42 Correct 1441 ms 231304 KB Output is correct
43 Correct 1268 ms 231352 KB Output is correct
44 Correct 1391 ms 230660 KB Output is correct
45 Correct 1644 ms 240908 KB Output is correct
46 Correct 4 ms 9816 KB Output is correct
47 Correct 4 ms 10072 KB Output is correct
48 Correct 4 ms 10072 KB Output is correct
49 Correct 4 ms 10072 KB Output is correct
50 Correct 1110 ms 220060 KB Output is correct
51 Correct 1212 ms 219912 KB Output is correct
52 Correct 1098 ms 220420 KB Output is correct
53 Correct 1252 ms 220472 KB Output is correct
54 Correct 261 ms 185480 KB Output is correct
55 Correct 280 ms 182176 KB Output is correct
56 Correct 268 ms 185876 KB Output is correct
57 Correct 279 ms 182412 KB Output is correct
58 Correct 512 ms 243760 KB Output is correct
59 Correct 507 ms 243100 KB Output is correct
60 Correct 482 ms 243416 KB Output is correct
61 Correct 522 ms 243224 KB Output is correct
62 Correct 552 ms 224748 KB Output is correct
63 Correct 515 ms 223060 KB Output is correct
64 Correct 463 ms 224672 KB Output is correct
65 Correct 567 ms 223240 KB Output is correct
66 Correct 4 ms 10072 KB Output is correct
67 Correct 5 ms 10064 KB Output is correct
68 Correct 6 ms 10072 KB Output is correct
69 Correct 7 ms 10072 KB Output is correct
70 Correct 6 ms 10276 KB Output is correct
71 Correct 7 ms 10080 KB Output is correct
72 Correct 6 ms 10328 KB Output is correct
73 Correct 22 ms 14424 KB Output is correct
74 Correct 544 ms 243392 KB Output is correct
75 Correct 524 ms 243168 KB Output is correct
76 Correct 484 ms 243392 KB Output is correct
77 Correct 528 ms 243052 KB Output is correct
78 Correct 417 ms 125620 KB Output is correct
79 Correct 443 ms 125628 KB Output is correct
80 Correct 599 ms 125540 KB Output is correct
81 Correct 606 ms 125436 KB Output is correct
82 Correct 525 ms 125472 KB Output is correct
83 Correct 620 ms 125320 KB Output is correct
84 Correct 890 ms 243488 KB Output is correct
85 Correct 971 ms 243368 KB Output is correct
86 Correct 1260 ms 243544 KB Output is correct
87 Correct 1350 ms 243100 KB Output is correct
88 Correct 1164 ms 243440 KB Output is correct
89 Correct 1446 ms 243196 KB Output is correct
90 Correct 8 ms 10072 KB Output is correct
91 Correct 6 ms 9928 KB Output is correct
92 Correct 7 ms 10072 KB Output is correct
93 Correct 5 ms 10072 KB Output is correct
94 Correct 7 ms 10072 KB Output is correct
95 Correct 6 ms 10328 KB Output is correct
96 Correct 19 ms 13912 KB Output is correct
97 Correct 596 ms 224808 KB Output is correct
98 Correct 582 ms 223040 KB Output is correct
99 Correct 529 ms 224744 KB Output is correct
100 Correct 546 ms 223144 KB Output is correct
101 Correct 475 ms 116288 KB Output is correct
102 Correct 626 ms 116184 KB Output is correct
103 Correct 618 ms 116224 KB Output is correct
104 Correct 649 ms 115776 KB Output is correct
105 Correct 523 ms 116292 KB Output is correct
106 Correct 604 ms 115544 KB Output is correct
107 Correct 974 ms 224788 KB Output is correct
108 Correct 1340 ms 224784 KB Output is correct
109 Correct 1375 ms 224740 KB Output is correct
110 Correct 1412 ms 223144 KB Output is correct
111 Correct 1183 ms 224876 KB Output is correct
112 Correct 1405 ms 223040 KB Output is correct
113 Correct 877 ms 120684 KB Output is correct
114 Correct 952 ms 121296 KB Output is correct
115 Correct 981 ms 121264 KB Output is correct
116 Correct 1139 ms 122008 KB Output is correct
117 Correct 1010 ms 122240 KB Output is correct
118 Correct 1081 ms 120932 KB Output is correct
119 Correct 592 ms 117144 KB Output is correct
120 Correct 534 ms 117224 KB Output is correct
121 Correct 1155 ms 117628 KB Output is correct
122 Correct 931 ms 117072 KB Output is correct
123 Correct 931 ms 116224 KB Output is correct
124 Correct 872 ms 115728 KB Output is correct
125 Correct 967 ms 119400 KB Output is correct
126 Correct 983 ms 119032 KB Output is correct
127 Correct 975 ms 119152 KB Output is correct
128 Correct 994 ms 119476 KB Output is correct
129 Correct 911 ms 118920 KB Output is correct
130 Correct 1000 ms 119564 KB Output is correct
131 Correct 983 ms 123132 KB Output is correct
132 Correct 922 ms 124060 KB Output is correct
133 Correct 1014 ms 123232 KB Output is correct
134 Correct 692 ms 114340 KB Output is correct
135 Correct 747 ms 114484 KB Output is correct
136 Correct 814 ms 114468 KB Output is correct
137 Correct 739 ms 114748 KB Output is correct
138 Correct 835 ms 114804 KB Output is correct
139 Correct 795 ms 114544 KB Output is correct
140 Correct 287 ms 97988 KB Output is correct
141 Correct 280 ms 97788 KB Output is correct
142 Correct 276 ms 97068 KB Output is correct
143 Correct 283 ms 97984 KB Output is correct
144 Correct 315 ms 96836 KB Output is correct
145 Correct 425 ms 125688 KB Output is correct
146 Correct 456 ms 125700 KB Output is correct
147 Correct 569 ms 125576 KB Output is correct
148 Correct 650 ms 125416 KB Output is correct
149 Correct 528 ms 125452 KB Output is correct
150 Correct 599 ms 125560 KB Output is correct
151 Correct 435 ms 116240 KB Output is correct
152 Correct 589 ms 116228 KB Output is correct
153 Correct 528 ms 116240 KB Output is correct
154 Correct 566 ms 115536 KB Output is correct
155 Correct 490 ms 116372 KB Output is correct
156 Correct 603 ms 115724 KB Output is correct
157 Correct 1940 ms 234732 KB Output is correct
158 Correct 1998 ms 235628 KB Output is correct
159 Correct 2314 ms 234652 KB Output is correct
160 Correct 2416 ms 233896 KB Output is correct
161 Correct 2161 ms 236608 KB Output is correct
162 Correct 2410 ms 236084 KB Output is correct
163 Correct 1125 ms 227180 KB Output is correct
164 Correct 1127 ms 226644 KB Output is correct
165 Correct 2000 ms 227264 KB Output is correct
166 Correct 2108 ms 226760 KB Output is correct
167 Correct 1943 ms 224760 KB Output is correct
168 Correct 1891 ms 223776 KB Output is correct
169 Correct 1791 ms 231088 KB Output is correct
170 Correct 2152 ms 230544 KB Output is correct
171 Correct 2111 ms 230788 KB Output is correct
172 Correct 2250 ms 230200 KB Output is correct
173 Correct 2047 ms 230748 KB Output is correct
174 Correct 2200 ms 231560 KB Output is correct
175 Correct 2001 ms 238988 KB Output is correct
176 Correct 2154 ms 240096 KB Output is correct
177 Correct 2476 ms 242944 KB Output is correct
178 Correct 1547 ms 220460 KB Output is correct
179 Correct 1819 ms 220108 KB Output is correct
180 Correct 1959 ms 221680 KB Output is correct
181 Correct 1666 ms 219868 KB Output is correct
182 Correct 1824 ms 220564 KB Output is correct
183 Correct 1743 ms 220144 KB Output is correct
184 Correct 529 ms 185600 KB Output is correct
185 Correct 575 ms 185524 KB Output is correct
186 Correct 585 ms 183124 KB Output is correct
187 Correct 542 ms 185680 KB Output is correct
188 Correct 657 ms 182700 KB Output is correct