Submission #848741

# Submission time Handle Problem Language Result Execution time Memory
848741 2023-09-13T12:17:24 Z danikoynov Jail (JOI22_jail) C++14
100 / 100
1484 ms 314280 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 2e5 + 10;

int n, m, s[maxn], t[maxn], parent[maxn];
vector < int > adj[maxn], children[maxn];
void input()
{
    cin >> n;
    for (int i = 1; i < n; i ++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cin >> m;
    for (int i = 1; i <= m; i ++)
    {
        cin >> s[i] >> t[i];
    }

}

int tin[maxn], tout[maxn], occ[2 * maxn], depth[maxn], timer;
int sub[maxn], heavy[maxn];
void euler(int v = 1, int p = -1)
{
    tin[v] = ++ timer;
    occ[timer] = v;
    sub[v] = 1;
    heavy[v] = -1;
    parent[v] = p;
    for (int u : adj[v])
    {
        if (u == p)
            continue;
        children[v].push_back(u);
        depth[u] = depth[v] + 1;
        euler(u, v);
        if (heavy[v] == -1 || sub[u] > sub[heavy[v]])
            heavy[v] = u;
        sub[v] += sub[u];
        occ[++ timer] = v;
    }
    tout[v] = timer;
}

const int maxlog = 20;
int dp[maxlog][maxn * 2], lg[2 * maxn];

void build_sparse_table()
{
    for (int i = 1; i <= timer; i ++)
    {
        dp[0][i] = occ[i];
        lg[i] = lg[i / 2] + 1;
    }

    for (int j = 1; j < lg[timer]; j ++)
    {
        for (int i = 1; i <= timer - (1 << j) + 1; i ++)
        {
            dp[j][i] = dp[j - 1][i + (1 << (j - 1))];
            if (depth[dp[j - 1][i]] < depth[dp[j][i]])
                dp[j][i] = dp[j - 1][i];
        }
    }
}

int get_lca(int v, int u)
{
    int l = tin[v], r = tin[u];
    if (l > r)
        swap(l, r);
    int len = lg[r - l + 1] - 1;
    int lca = dp[len][r - (1 << len) + 1];
    if (depth[dp[len][l]] < depth[lca])
        lca = dp[len][l];
    return lca;
}

vector < int > graph[10 * maxn];
bool is_cycle;

bool in_subtree(int v, int u)
{
    return (tin[v] <= tin[u] && tout[v] >= tout[u]);
}

bool on_path(int v, int u, int w)
{

    int lca = get_lca(v, u);
    if (in_subtree(lca, w) && in_subtree(w, v))
        return true;
    if (in_subtree(lca, w) && in_subtree(w, u))
        return true;
    return false;
}

void check_prisoners(int i, int j)
{
    /**if (on_path(s[i], t[i], s[j]) && on_path(s[i], t[i], t[j]))
    {
        is_cycle = true;
        return;
    }*/

    if (on_path(s[i], t[i], s[j]))
    {
        graph[i].push_back(j);
        return;
    }

    if (on_path(s[i], t[i], t[j]))
    {
        graph[j].push_back(i);
        return;
    }
}

vector < pair < int, int > > link[maxn];
set < pair < int, int > > loc_set[maxn];

bool cmp(pair < int, int > di, pair < int, int > dj)
{
    int i = di.second, j = dj.second;
    int d1 = depth[s[i]] + depth[t[i]] - 2 * depth[get_lca(s[i], t[i])];
    int d2 = depth[s[j]] + depth[t[j]] - 2 * depth[get_lca(s[j], t[j])];
    return d1 > d2;
}

bool check_range(int idx, int left, int right)
{
    pair < int, int > cur = {left, -1};
    set < pair < int, int > > :: iterator it = loc_set[idx].lower_bound(cur);
    if (it == loc_set[idx].end())
        return false;
    if (it -> first <= right)
        return true;
    return false;
}

int find_child(int v, int u)
{
    int lf = 0, rf = (int)(children[v].size()) - 1;
    while(lf <= rf)
    {
        int mf = (lf + rf) / 2;
        if (tout[children[v][mf]] < tin[u])
            lf = mf + 1;
        else
            rf = mf - 1;
    }
    return children[v][lf];

}
void dfs(int v, int p)
{

    for (int u : adj[v])
    {
        if (u == p)
            continue;
        dfs(u, v);
        if (loc_set[u].size() > loc_set[v].size())
            swap(loc_set[u], loc_set[v]);

        for (pair < int, int > cur : loc_set[u])
        {
            pair < int, int > par = {tin[s[cur.second]], cur.second};
            if (tin[s[cur.second]] == cur.first)
                par.first = tin[t[cur.second]];
            if (loc_set[v].find(par) != loc_set[v].end())
                loc_set[v].erase(par);
            else
                loc_set[v].insert(cur);
        }
    }

    sort(link[v].begin(), link[v].end(), cmp);

    for (pair < int, int > cur : link[v])
    {
        pair < int, int > par = {tin[s[cur.second]], cur.second};
        if (tin[s[cur.second]] == cur.first)
            par.first = tin[t[cur.second]];
        ///cout << "here " << cur.first << " " << cur.second << " " << par.first << " " << par.second << " " << tin[s[cur.second]] << endl;
        if (loc_set[v].find(par) != loc_set[v].end())
        {
            loc_set[v].erase(par);
            continue;
        }
        int idx = cur.second, u = s[idx];
        if (u == v)
            u = t[idx];

        if (!in_subtree(u, v))
        {
            if (check_range(v, tin[u], tout[u]))
                is_cycle = true;
        }
        else
        {
            int child = find_child(u, v);
            ///cout << "HERE " << child << " " << u << endl;
            if (check_range(v, 1, tin[child] - 1) || check_range(v, tout[child] + 1, timer))
            {
                ///cout << "FOUND CYCLE " << v << " " << u << " " << child << endl;
                is_cycle = true;
            }
        }
        loc_set[v].insert(cur);
    }
    /**cout << v << " : " << p << endl;
    for (pair < int, int > cur : loc_set[v])
        cout << cur.first << " " << cur.second << endl;
    cout << "cycle " << is_cycle << endl;
        cout << "-------------" << endl;*/
}


struct chain
{
    int top, left, right;

} ch[maxn];

int ord[maxn], ch_idx[maxn], ch_cnt, to, ch_pos[maxn];


void hld(int v)
{
    ch_idx[v] = ch_cnt;
    ord[++ to] = v;
    ch[ch_idx[v]].right = to;
    ch_pos[v] = to;
    if (heavy[v] != -1)
        hld(heavy[v]);

    for (int u : children[v])
    {
        if (u == heavy[v])
            continue;

        ch_cnt ++;
        ch[ch_cnt].top = v;
        ch[ch_cnt].left = to + 1;
        ch[ch_cnt].right = to;
        hld(u);
    }
}

vector < int > ver_start[maxn], ver_end[maxn]; /// might be replaced
void add_edge(int v, int u)
{
    graph[v].push_back(u);
    ///cout << "edge " << v << " " << u << endl;
}
void build_forward_tree(int root, int left, int right)
{
    ///cout << root + m << " : " << left << " " << right << endl;
    if (left == right)
    {
        for (int v : ver_start[left])
            add_edge(root + m, v);
        ///graph[root + m].push_back(v);
        return;
    }

    int mid = (left + right) / 2;
    add_edge(root + m, root * 2 + m);
    add_edge(root + m, root * 2 + 1 + m);
    ///graph[root + m].push_back(root * 2 + m);
    ///graph[root + m].push_back(root * 2  + 1 + m);

    build_forward_tree(root * 2, left, mid);
    build_forward_tree(root * 2 + 1, mid + 1, right);
}

vector < int > bkt[maxn * 4];
void build_backward_tree(int root, int left, int right)
{
    bkt[root].clear();
    if (left == right)
    {
        for (int v : ver_end[left])
        {
            bkt[root].push_back(v);
            add_edge(v, root + m + 4 * n);
            ///graph[v].push_back(root + m + 4 * n);
            ///cout << v << " here " << left << endl;
        }
        return;
    }

    int mid = (left + right) / 2;
    ///add_edge(root * 2 + m + 4 * n, root + m + 4 * n);
    ///add_edge(root * 2 + 1 + m + 4 * n, root + m + 4 * n);

    ///graph[root * 2 + m + 4 * n].push_back(root + m + 4 * n);
    ///graph[root * 2  + 1 + m + 4 * n].push_back(root + m + 4 * n);

    build_backward_tree(root * 2, left, mid);
    build_backward_tree(root * 2 + 1, mid + 1, right);

    for (int v : bkt[root * 2])
        bkt[root].push_back(v);
    for (int v : bkt[root * 2 + 1])
        bkt[root].push_back(v);
    for (int v : bkt[root])
        add_edge(v, root + m + 4 * n);

}

void add_forward(int root, int left, int right, int qleft, int qright, int val)
{
    if (left > qright || right < qleft)
        return;

    if (left >= qleft && right <= qright)
    {
        add_edge(val, root + m);
        ///graph[val].push_back(root + m);
        return;
    }

    int mid = (left + right) / 2;
    add_forward(root * 2, left, mid, qleft, qright, val);
    add_forward(root * 2 + 1, mid + 1, right, qleft, qright, val);
}

void add_backward(int root, int left, int right, int qleft, int qright, int val)
{
    if (left > qright || right < qleft)
        return;

    if (left >= qleft && right <= qright)
    {
        add_edge(root + m + 4 * n, val);

        return;
    }

    int mid = (left + right) / 2;
    add_backward(root * 2, left, mid, qleft, qright, val);
    add_backward(root * 2 + 1, mid + 1, right, qleft, qright, val);
}

void add_path_forward(int v, int lca, int idx)
{

    while(ch_idx[v] != ch_idx[lca])
    {

        add_forward(1, 1, n, ch[ch_idx[v]].left, ch_pos[v], idx);
        ///add_backward(1, 1, n, ch[ch_idx[v]].left, ch_pos[v], idx);
        v = ch[ch_idx[v]].top;
    }
    ///cout << "idx " << idx << " " << ch_pos[lca] << " " << ch_pos[v] << endl;

    add_forward(1, 1, n, ch_pos[lca], ch_pos[v], idx);
    ///add_backward(1, 1, n, ch_pos[lca], ch_pos[v], idx);
}

void add_path_backward(int v, int lca, int idx)
{

    while(ch_idx[v] != ch_idx[lca])
    {

        ///add_forward(1, 1, n, ch[ch_idx[v]].left, ch_pos[v], idx);
        add_backward(1, 1, n, ch[ch_idx[v]].left, ch_pos[v], idx);
        v = ch[ch_idx[v]].top;
    }
    ///cout << "idx " << idx << " " << ch_pos[lca] << " " << ch_pos[v] << endl;

    ///add_forward(1, 1, n, ch_pos[lca], ch_pos[v], idx);
    add_backward(1, 1, n, ch_pos[lca], ch_pos[v], idx);
}
void build_graph()
{


    for (int i = 1; i <= m; i ++)
    {
        link[s[i]].push_back({tin[t[i]], i});
        link[t[i]].push_back({tin[s[i]], i});

    }

    dfs(1, -1);

    ch_cnt = 0;
    to = 0;
    ch[++ ch_cnt].top = 0;
    ch[ch_cnt].left = 1;
    ch[ch_cnt].right = 0;
    hld(1);
    /**for (int i = 1; i <= n; i ++)
        cout << ch_pos[i] << " ";
    cout << endl;*/
    for (int i = 1; i <= m; i ++)
    {
                ver_start[ch_pos[s[i]]].push_back(i);
        ver_end[ch_pos[t[i]]].push_back(i);
    }
    build_backward_tree(1, 1, n);
    build_forward_tree(1, 1, n);

    for (int i = 1; i <= m; i ++)
    {
        int lca = get_lca(s[i], t[i]);

        if (depth[s[i]] + depth[t[i]] - 2 * depth[lca] != 1)
        {

            int v = s[i], u = t[i];
            if (lca != v && lca != u)
            {
                v = parent[v];
                u = parent[u];
            }
            else if (lca == v)
            {
                v = find_child(v, u);
                u = parent[u];
            }
            else if (lca == u)
            {
                u = find_child(u, v);
                v = parent[v];

            }
            lca = get_lca(v, u);
            ///cout << "path " << v << " : " << u << endl;
            add_path_forward(v, lca, i);
            add_path_forward(u, lca, i);
            add_path_backward(v, lca, i);
            add_path_backward(u, lca, i);
        }

        for (pair < int, int > cur : link[s[i]])
        {
            if (i != cur.second)
                check_prisoners(i, cur.second);
        }

        for (pair < int, int > cur : link[t[i]])
        {
            if (i != cur.second)
                check_prisoners(i, cur.second);
        }



    }
    /**for (int i = 1; i <= m; i ++)
    {
        for (int j = 1; j <= m; j ++)
        {
            if (i != j)
                check_prisoners(i, j);
        }
    }*/
}

int used[maxn];

void check_dag(int v)
{
    used[v] = 1;
    for (int u : graph[v])
    {
        if (used[u] == 2)
            continue;
        ///cout << v << " : " << u << endl;
        if (used[u] == 1)
            is_cycle = 1;
        else
        {
            check_dag(u);
        }
    }
    used[v] = 2;
}

void check_graph()
{
    for (int i = 1; i <= m + 8 * n; i ++)
    {
        if (!used[i])
            check_dag(i);
    }

    if (is_cycle)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

void clear_data()
{
    is_cycle = false;
    for (int i = 1; i <= m + 8 * n; i ++)
    {
        bkt[i].clear();

        graph[i].clear(), used[i] = 0;
    }

    for (int i = 1; i <= ch_cnt; i ++)
    {
        ch[i].top = ch[i].left = ch[i].right = 0;
    }

    for (int i = 1; i <= n; i ++)
    {
        ch_pos[i] = 0;
        ch_idx[i]=  0;
        ord[i] = 0;
    }
    ch_cnt = 0;
    to = 0;
    for (int i = 0; i <= n; i ++)
    {
        tin[i] = 0;
        tout[i] = 0;
        adj[i].clear();
        link[i].clear();
        ver_start[i].clear();
        ver_end[i].clear();
        children[i].clear();
        loc_set[i].clear();
    }


    timer = 0;
}

int test_num;
void solve()
{
    test_num ++;
    /**if (test_num <= 6)
    {
        cout << "SKIPPED" << endl;
        return;
    }*/
    input();
    euler();
    build_sparse_table();
    build_graph();
    check_graph();
    clear_data();

}

int main()
{
    speed();
    //freopen("test.txt", "r", stdin);
    int q;
    cin >> q;
    while(q --)
        solve();
    return 0;
}
/**
1
7
1 2
2 3
3 4
4 5
3 6
6 7
2
4 1
5 7

1
4
1 2
2 3
3 4
2
1 3
2 4


1
5
1 2
1 3
2 4
2 5
1
4 5

*/
# Verdict Execution time Memory Grader output
1 Correct 27 ms 117584 KB Output is correct
2 Correct 27 ms 117340 KB Output is correct
3 Correct 23 ms 113240 KB Output is correct
4 Correct 37 ms 123484 KB Output is correct
5 Correct 50 ms 123484 KB Output is correct
6 Correct 32 ms 123684 KB Output is correct
7 Correct 25 ms 123644 KB Output is correct
8 Correct 27 ms 123740 KB Output is correct
9 Correct 75 ms 134768 KB Output is correct
10 Correct 95 ms 171740 KB Output is correct
11 Correct 31 ms 119384 KB Output is correct
12 Correct 103 ms 123664 KB Output is correct
13 Correct 223 ms 200496 KB Output is correct
14 Correct 212 ms 200656 KB Output is correct
15 Correct 438 ms 206400 KB Output is correct
16 Correct 935 ms 247612 KB Output is correct
17 Correct 301 ms 212172 KB Output is correct
18 Correct 230 ms 218896 KB Output is correct
19 Correct 257 ms 208752 KB Output is correct
20 Correct 257 ms 208756 KB Output is correct
21 Correct 301 ms 211712 KB Output is correct
22 Correct 157 ms 198372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 117340 KB Output is correct
2 Correct 23 ms 113340 KB Output is correct
3 Correct 25 ms 123508 KB Output is correct
4 Correct 25 ms 123484 KB Output is correct
5 Correct 25 ms 123480 KB Output is correct
6 Correct 26 ms 123484 KB Output is correct
7 Correct 25 ms 123484 KB Output is correct
8 Correct 24 ms 123484 KB Output is correct
9 Correct 25 ms 123484 KB Output is correct
10 Correct 26 ms 123480 KB Output is correct
11 Correct 25 ms 123484 KB Output is correct
12 Correct 24 ms 123484 KB Output is correct
13 Correct 27 ms 123576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 117340 KB Output is correct
2 Correct 23 ms 113340 KB Output is correct
3 Correct 25 ms 123508 KB Output is correct
4 Correct 25 ms 123484 KB Output is correct
5 Correct 25 ms 123480 KB Output is correct
6 Correct 26 ms 123484 KB Output is correct
7 Correct 25 ms 123484 KB Output is correct
8 Correct 24 ms 123484 KB Output is correct
9 Correct 25 ms 123484 KB Output is correct
10 Correct 26 ms 123480 KB Output is correct
11 Correct 25 ms 123484 KB Output is correct
12 Correct 24 ms 123484 KB Output is correct
13 Correct 27 ms 123576 KB Output is correct
14 Correct 23 ms 117336 KB Output is correct
15 Correct 23 ms 117336 KB Output is correct
16 Correct 24 ms 123660 KB Output is correct
17 Correct 24 ms 123480 KB Output is correct
18 Correct 25 ms 123484 KB Output is correct
19 Correct 23 ms 117340 KB Output is correct
20 Correct 25 ms 123484 KB Output is correct
21 Correct 25 ms 123484 KB Output is correct
22 Correct 25 ms 123484 KB Output is correct
23 Correct 25 ms 117332 KB Output is correct
24 Correct 24 ms 123484 KB Output is correct
25 Correct 25 ms 123444 KB Output is correct
26 Correct 24 ms 123484 KB Output is correct
27 Correct 25 ms 123484 KB Output is correct
28 Correct 23 ms 119388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 117340 KB Output is correct
2 Correct 23 ms 113340 KB Output is correct
3 Correct 25 ms 123508 KB Output is correct
4 Correct 25 ms 123484 KB Output is correct
5 Correct 25 ms 123480 KB Output is correct
6 Correct 26 ms 123484 KB Output is correct
7 Correct 25 ms 123484 KB Output is correct
8 Correct 24 ms 123484 KB Output is correct
9 Correct 25 ms 123484 KB Output is correct
10 Correct 26 ms 123480 KB Output is correct
11 Correct 25 ms 123484 KB Output is correct
12 Correct 24 ms 123484 KB Output is correct
13 Correct 27 ms 123576 KB Output is correct
14 Correct 23 ms 117336 KB Output is correct
15 Correct 23 ms 117336 KB Output is correct
16 Correct 24 ms 123660 KB Output is correct
17 Correct 24 ms 123480 KB Output is correct
18 Correct 25 ms 123484 KB Output is correct
19 Correct 23 ms 117340 KB Output is correct
20 Correct 25 ms 123484 KB Output is correct
21 Correct 25 ms 123484 KB Output is correct
22 Correct 25 ms 123484 KB Output is correct
23 Correct 25 ms 117332 KB Output is correct
24 Correct 24 ms 123484 KB Output is correct
25 Correct 25 ms 123444 KB Output is correct
26 Correct 24 ms 123484 KB Output is correct
27 Correct 25 ms 123484 KB Output is correct
28 Correct 23 ms 119388 KB Output is correct
29 Correct 26 ms 123736 KB Output is correct
30 Correct 27 ms 123740 KB Output is correct
31 Correct 27 ms 123740 KB Output is correct
32 Correct 29 ms 123840 KB Output is correct
33 Correct 25 ms 123688 KB Output is correct
34 Correct 27 ms 123484 KB Output is correct
35 Correct 27 ms 123504 KB Output is correct
36 Correct 26 ms 123728 KB Output is correct
37 Correct 25 ms 123600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 117340 KB Output is correct
2 Correct 23 ms 113340 KB Output is correct
3 Correct 25 ms 123508 KB Output is correct
4 Correct 25 ms 123484 KB Output is correct
5 Correct 25 ms 123480 KB Output is correct
6 Correct 26 ms 123484 KB Output is correct
7 Correct 25 ms 123484 KB Output is correct
8 Correct 24 ms 123484 KB Output is correct
9 Correct 25 ms 123484 KB Output is correct
10 Correct 26 ms 123480 KB Output is correct
11 Correct 25 ms 123484 KB Output is correct
12 Correct 24 ms 123484 KB Output is correct
13 Correct 27 ms 123576 KB Output is correct
14 Correct 23 ms 117336 KB Output is correct
15 Correct 23 ms 117336 KB Output is correct
16 Correct 24 ms 123660 KB Output is correct
17 Correct 24 ms 123480 KB Output is correct
18 Correct 25 ms 123484 KB Output is correct
19 Correct 23 ms 117340 KB Output is correct
20 Correct 25 ms 123484 KB Output is correct
21 Correct 25 ms 123484 KB Output is correct
22 Correct 25 ms 123484 KB Output is correct
23 Correct 25 ms 117332 KB Output is correct
24 Correct 24 ms 123484 KB Output is correct
25 Correct 25 ms 123444 KB Output is correct
26 Correct 24 ms 123484 KB Output is correct
27 Correct 25 ms 123484 KB Output is correct
28 Correct 23 ms 119388 KB Output is correct
29 Correct 26 ms 123736 KB Output is correct
30 Correct 27 ms 123740 KB Output is correct
31 Correct 27 ms 123740 KB Output is correct
32 Correct 29 ms 123840 KB Output is correct
33 Correct 25 ms 123688 KB Output is correct
34 Correct 27 ms 123484 KB Output is correct
35 Correct 27 ms 123504 KB Output is correct
36 Correct 26 ms 123728 KB Output is correct
37 Correct 25 ms 123600 KB Output is correct
38 Correct 72 ms 134920 KB Output is correct
39 Correct 92 ms 171592 KB Output is correct
40 Correct 89 ms 134404 KB Output is correct
41 Correct 98 ms 134232 KB Output is correct
42 Correct 75 ms 134940 KB Output is correct
43 Correct 59 ms 133112 KB Output is correct
44 Correct 50 ms 128316 KB Output is correct
45 Correct 127 ms 151892 KB Output is correct
46 Correct 113 ms 151976 KB Output is correct
47 Correct 91 ms 161356 KB Output is correct
48 Correct 90 ms 161304 KB Output is correct
49 Correct 97 ms 152144 KB Output is correct
50 Correct 100 ms 152144 KB Output is correct
51 Correct 86 ms 154504 KB Output is correct
52 Correct 86 ms 154440 KB Output is correct
53 Correct 43 ms 132956 KB Output is correct
54 Correct 110 ms 151588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 117336 KB Output is correct
2 Correct 24 ms 117424 KB Output is correct
3 Correct 22 ms 117340 KB Output is correct
4 Correct 23 ms 113244 KB Output is correct
5 Correct 32 ms 119388 KB Output is correct
6 Correct 25 ms 123732 KB Output is correct
7 Correct 24 ms 123484 KB Output is correct
8 Correct 23 ms 117336 KB Output is correct
9 Correct 23 ms 117340 KB Output is correct
10 Correct 23 ms 123484 KB Output is correct
11 Correct 24 ms 119404 KB Output is correct
12 Correct 27 ms 123500 KB Output is correct
13 Correct 74 ms 123616 KB Output is correct
14 Correct 93 ms 123480 KB Output is correct
15 Correct 83 ms 123668 KB Output is correct
16 Correct 178 ms 160596 KB Output is correct
17 Correct 596 ms 209228 KB Output is correct
18 Correct 1144 ms 270192 KB Output is correct
19 Correct 266 ms 171088 KB Output is correct
20 Correct 276 ms 171264 KB Output is correct
21 Correct 268 ms 171348 KB Output is correct
22 Correct 527 ms 208240 KB Output is correct
23 Correct 389 ms 205996 KB Output is correct
24 Correct 437 ms 208096 KB Output is correct
25 Correct 426 ms 207040 KB Output is correct
26 Correct 445 ms 207204 KB Output is correct
27 Correct 534 ms 213348 KB Output is correct
28 Correct 535 ms 214884 KB Output is correct
29 Correct 547 ms 211816 KB Output is correct
30 Correct 352 ms 190732 KB Output is correct
31 Correct 371 ms 191948 KB Output is correct
32 Correct 356 ms 190412 KB Output is correct
33 Correct 361 ms 192160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 117584 KB Output is correct
2 Correct 27 ms 117340 KB Output is correct
3 Correct 23 ms 113240 KB Output is correct
4 Correct 37 ms 123484 KB Output is correct
5 Correct 50 ms 123484 KB Output is correct
6 Correct 32 ms 123684 KB Output is correct
7 Correct 25 ms 123644 KB Output is correct
8 Correct 27 ms 123740 KB Output is correct
9 Correct 75 ms 134768 KB Output is correct
10 Correct 95 ms 171740 KB Output is correct
11 Correct 31 ms 119384 KB Output is correct
12 Correct 103 ms 123664 KB Output is correct
13 Correct 223 ms 200496 KB Output is correct
14 Correct 212 ms 200656 KB Output is correct
15 Correct 438 ms 206400 KB Output is correct
16 Correct 935 ms 247612 KB Output is correct
17 Correct 301 ms 212172 KB Output is correct
18 Correct 230 ms 218896 KB Output is correct
19 Correct 257 ms 208752 KB Output is correct
20 Correct 257 ms 208756 KB Output is correct
21 Correct 301 ms 211712 KB Output is correct
22 Correct 157 ms 198372 KB Output is correct
23 Correct 24 ms 117340 KB Output is correct
24 Correct 23 ms 113340 KB Output is correct
25 Correct 25 ms 123508 KB Output is correct
26 Correct 25 ms 123484 KB Output is correct
27 Correct 25 ms 123480 KB Output is correct
28 Correct 26 ms 123484 KB Output is correct
29 Correct 25 ms 123484 KB Output is correct
30 Correct 24 ms 123484 KB Output is correct
31 Correct 25 ms 123484 KB Output is correct
32 Correct 26 ms 123480 KB Output is correct
33 Correct 25 ms 123484 KB Output is correct
34 Correct 24 ms 123484 KB Output is correct
35 Correct 27 ms 123576 KB Output is correct
36 Correct 23 ms 117336 KB Output is correct
37 Correct 23 ms 117336 KB Output is correct
38 Correct 24 ms 123660 KB Output is correct
39 Correct 24 ms 123480 KB Output is correct
40 Correct 25 ms 123484 KB Output is correct
41 Correct 23 ms 117340 KB Output is correct
42 Correct 25 ms 123484 KB Output is correct
43 Correct 25 ms 123484 KB Output is correct
44 Correct 25 ms 123484 KB Output is correct
45 Correct 25 ms 117332 KB Output is correct
46 Correct 24 ms 123484 KB Output is correct
47 Correct 25 ms 123444 KB Output is correct
48 Correct 24 ms 123484 KB Output is correct
49 Correct 25 ms 123484 KB Output is correct
50 Correct 23 ms 119388 KB Output is correct
51 Correct 26 ms 123736 KB Output is correct
52 Correct 27 ms 123740 KB Output is correct
53 Correct 27 ms 123740 KB Output is correct
54 Correct 29 ms 123840 KB Output is correct
55 Correct 25 ms 123688 KB Output is correct
56 Correct 27 ms 123484 KB Output is correct
57 Correct 27 ms 123504 KB Output is correct
58 Correct 26 ms 123728 KB Output is correct
59 Correct 25 ms 123600 KB Output is correct
60 Correct 72 ms 134920 KB Output is correct
61 Correct 92 ms 171592 KB Output is correct
62 Correct 89 ms 134404 KB Output is correct
63 Correct 98 ms 134232 KB Output is correct
64 Correct 75 ms 134940 KB Output is correct
65 Correct 59 ms 133112 KB Output is correct
66 Correct 50 ms 128316 KB Output is correct
67 Correct 127 ms 151892 KB Output is correct
68 Correct 113 ms 151976 KB Output is correct
69 Correct 91 ms 161356 KB Output is correct
70 Correct 90 ms 161304 KB Output is correct
71 Correct 97 ms 152144 KB Output is correct
72 Correct 100 ms 152144 KB Output is correct
73 Correct 86 ms 154504 KB Output is correct
74 Correct 86 ms 154440 KB Output is correct
75 Correct 43 ms 132956 KB Output is correct
76 Correct 110 ms 151588 KB Output is correct
77 Correct 23 ms 117336 KB Output is correct
78 Correct 24 ms 117424 KB Output is correct
79 Correct 22 ms 117340 KB Output is correct
80 Correct 23 ms 113244 KB Output is correct
81 Correct 32 ms 119388 KB Output is correct
82 Correct 25 ms 123732 KB Output is correct
83 Correct 24 ms 123484 KB Output is correct
84 Correct 23 ms 117336 KB Output is correct
85 Correct 23 ms 117340 KB Output is correct
86 Correct 23 ms 123484 KB Output is correct
87 Correct 24 ms 119404 KB Output is correct
88 Correct 27 ms 123500 KB Output is correct
89 Correct 74 ms 123616 KB Output is correct
90 Correct 93 ms 123480 KB Output is correct
91 Correct 83 ms 123668 KB Output is correct
92 Correct 178 ms 160596 KB Output is correct
93 Correct 596 ms 209228 KB Output is correct
94 Correct 1144 ms 270192 KB Output is correct
95 Correct 266 ms 171088 KB Output is correct
96 Correct 276 ms 171264 KB Output is correct
97 Correct 268 ms 171348 KB Output is correct
98 Correct 527 ms 208240 KB Output is correct
99 Correct 389 ms 205996 KB Output is correct
100 Correct 437 ms 208096 KB Output is correct
101 Correct 426 ms 207040 KB Output is correct
102 Correct 445 ms 207204 KB Output is correct
103 Correct 534 ms 213348 KB Output is correct
104 Correct 535 ms 214884 KB Output is correct
105 Correct 547 ms 211816 KB Output is correct
106 Correct 352 ms 190732 KB Output is correct
107 Correct 371 ms 191948 KB Output is correct
108 Correct 356 ms 190412 KB Output is correct
109 Correct 361 ms 192160 KB Output is correct
110 Correct 94 ms 124752 KB Output is correct
111 Correct 57 ms 124268 KB Output is correct
112 Correct 478 ms 205812 KB Output is correct
113 Correct 209 ms 179280 KB Output is correct
114 Correct 372 ms 198360 KB Output is correct
115 Correct 92 ms 154148 KB Output is correct
116 Correct 296 ms 184344 KB Output is correct
117 Correct 1484 ms 314280 KB Output is correct
118 Correct 121 ms 153552 KB Output is correct
119 Correct 116 ms 153680 KB Output is correct
120 Correct 49 ms 138068 KB Output is correct
121 Correct 376 ms 188960 KB Output is correct
122 Correct 369 ms 188880 KB Output is correct
123 Correct 240 ms 185172 KB Output is correct
124 Correct 230 ms 185112 KB Output is correct
125 Correct 252 ms 187268 KB Output is correct
126 Correct 859 ms 245976 KB Output is correct
127 Correct 407 ms 208980 KB Output is correct
128 Correct 282 ms 207724 KB Output is correct
129 Correct 294 ms 207872 KB Output is correct
130 Correct 299 ms 207968 KB Output is correct