답안 #702978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
702978 2023-02-25T11:50:26 Z piOOE Jail (JOI22_jail) C++17
100 / 100
1122 ms 145164 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

class HLD {
public:
    vector<int> par, siz, head, tin, tout, ord, depth;

    int dfs1(int i, vector<vector<int>> &g) {
        for (int &t: g[i]) {
            if (t != par[i]) {
                depth[t] = depth[i] + 1;
                par[t] = i;
                siz[i] += dfs1(t, g);
                if (siz[t] > siz[g[i][0]] || g[i][0] == par[i]) swap(t, g[i][0]);
            }
        }
        return siz[i];
    }

    void dfs2(int i, int &T, const vector<vector<int>> &g) {
        tin[i] = T++;
        for (int t: g[i]) {
            if (t != par[i]) {
                head[t] = (T == tin[i] + 1 ? head[i] : t);
                dfs2(t, T, g);
            }
        }
        tout[i] = T;
    }

    HLD(vector<vector<int>> g, int r = 0)
            : par(g.size(), -1), siz(g.size(), 1), head(g.size(), r), tin(g.size()), ord(g.size()), tout(g.size()),
              depth(g.size()) {
        dfs1(r, g);
        int x = 0;
        dfs2(r, x, g);
        for (int i = 0; i < g.size(); ++i) ord[tin[i]] = i;
    }

    vector<pair<int, int>> path(int a, int b) {
        vector<pair<int, int>> res;
        for (;; b = par[head[b]]) {
            if (tin[b] < tin[a]) swap(a, b);
            if (tin[head[b]] <= tin[a]) {
                res.emplace_back(tin[a], tin[b] + 1);
                return res;
            }
            res.emplace_back(tin[head[b]], tin[b] + 1);
        }
    }

    pair<int, int> subtree(int i) {
        return {tin[i], tin[i] + siz[i]};
    }

    int dist(int a, int b) {
        return depth[a] + depth[b] - 2 * depth[lca(a, b)];
    }

    int lca(int a, int b) {
        for (;; b = par[head[b]]) {
            if (tin[b] < tin[a]) swap(a, b);
            if (tin[head[b]] <= tin[a]) return a;
        }
    }

    bool isp(int a, int b) {
        return tin[a] <= tin[b] && tout[a] >= tout[b];
    }
};

constexpr int N = 1.2e5, D = 256 * 1024;
constexpr int N_ = D + N * 17;

vector<int> g[N_];
int top = 0;
int used[N_], in[D], out[D];

int sz = 1;

void init(int n) {
    sz = 1 << __lg(n) + !!(n & (n - 1));

    for (int i = 1; i < sz + n; ++i) {
        in[i] = top++;
        out[i] = top++;
    }
}

void solve() {
    int n;
    cin >> n;

    vector<vector<int>> adj(n);

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

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

    HLD tree(adj);

    int m;
    cin >> m;

    top = m;

    vector<array<int, 2>> prisoner(m);

    for (auto &[s, t]: prisoner) {
        cin >> s >> t;
        s -= 1, t -= 1;
    }


    init(n);

    vector<vector<pair<int, int>>> same(n);

    for (int i = 0; i < m; ++i) {
        auto [S, T] = prisoner[i];

        if (S != T) {
            same[S].push_back({i, 0});
            same[T].push_back({i, 1});
        }

        auto path = tree.path(S, T);

        auto dfs = [&](auto dfs, int l, int r, int x, int lx, int rx) {
            if (l >= rx || lx >= r) return;
            if (l <= lx && rx <= r) {
                g[i].push_back(in[x]);
                g[out[x]].push_back(i);
                return;
            }

            int mid = lx + rx >> 1;
            dfs(dfs, l, r, x << 1, lx, mid), dfs(dfs, l, r, x << 1 | 1, mid, rx);
        };

        for (auto [lx, rx]: path) {
            if (lx == tree.tin[S]) lx++;
            if (rx == tree.tin[S] + 1) --rx;
            if (lx == tree.tin[T]) lx++;
            if (rx == tree.tin[T] + 1) --rx;

            assert(!(lx <= tree.tin[S] && tree.tin[S] < rx));
            assert(!(lx <= tree.tin[T] && tree.tin[T] < rx));

            if (lx < rx) {
                dfs(dfs, lx, rx, 1, 0, sz);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        if (same[i].size() == 2) {
            if (same[i][0].second == 0) {
                swap(same[i][0], same[i][1]);
            }

            g[same[i][0].first].push_back(same[i][1].first);
        }
    }

    for (int i = 0; i < m; ++i) {
        auto [S, T] = prisoner[i];

        S = tree.tin[S];
        T = tree.tin[T];

        for (int x = S + sz; x > 0; x >>= 1) {
            g[in[x]].push_back(i);
        }

        for (int x = T + sz; x > 0; x >>= 1) {
            g[i].push_back(out[x]);
        }
    }

    bool yay = true;

    memset(used, 0, sizeof(used[0]) * top);

    vector<int> stk;

    auto dfs = [&](auto self, int v) -> void {
        used[v] = 1;
        if (v < m) stk.push_back(v);

        for (int to: g[v]) {
            if (!used[to]) {
                self(self, to);
            } else if (used[to] == 1 && stk.back() != to) {
                yay = false;
            }
        }

        used[v] = 2;
        if (v < m) stk.pop_back();
    };

    for (int i = 0; i < top; ++i) {
        if (!used[i]) {
            dfs(dfs, i);
        }
    }

    for (int i = 0; i < top; ++i) {
        g[i].clear();
    }

    cout << (yay ? "Yes\n" : "No\n");
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int test = 1;
    cin >> test;

    while (test--) {
        solve();
    }

    return 0;
}

Compilation message

jail.cpp: In constructor 'HLD::HLD(std::vector<std::vector<int> >, int)':
jail.cpp:8:44: warning: 'HLD::ord' will be initialized after [-Wreorder]
    8 |     vector<int> par, siz, head, tin, tout, ord, depth;
      |                                            ^~~
jail.cpp:8:38: warning:   'std::vector<int> HLD::tout' [-Wreorder]
    8 |     vector<int> par, siz, head, tin, tout, ord, depth;
      |                                      ^~~~
jail.cpp:33:5: warning:   when initialized here [-Wreorder]
   33 |     HLD(vector<vector<int>> g, int r = 0)
      |     ^~~
jail.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i = 0; i < g.size(); ++i) ord[tin[i]] = i;
      |                         ~~^~~~~~~~~~
jail.cpp: In function 'void init(int)':
jail.cpp:84:23: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   84 |     sz = 1 << __lg(n) + !!(n & (n - 1));
      |               ~~~~~~~~^~~~~~~~~~~~~~~~~
jail.cpp: In instantiation of 'solve()::<lambda(auto:23, int, int, int, int, int)> [with auto:23 = solve()::<lambda(auto:23, int, int, int, int, int)>]':
jail.cpp:158:42:   required from here
jail.cpp:144:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  144 |             int mid = lx + rx >> 1;
      |                       ~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 29 ms 54336 KB Output is correct
3 Correct 26 ms 54280 KB Output is correct
4 Correct 48 ms 54420 KB Output is correct
5 Correct 63 ms 54412 KB Output is correct
6 Correct 29 ms 54444 KB Output is correct
7 Correct 29 ms 54356 KB Output is correct
8 Correct 31 ms 54476 KB Output is correct
9 Correct 86 ms 56460 KB Output is correct
10 Correct 85 ms 77720 KB Output is correct
11 Correct 45 ms 54404 KB Output is correct
12 Correct 92 ms 54444 KB Output is correct
13 Correct 215 ms 102528 KB Output is correct
14 Correct 205 ms 99972 KB Output is correct
15 Correct 407 ms 105868 KB Output is correct
16 Correct 854 ms 140188 KB Output is correct
17 Correct 262 ms 111948 KB Output is correct
18 Correct 219 ms 116824 KB Output is correct
19 Correct 234 ms 109772 KB Output is correct
20 Correct 242 ms 109968 KB Output is correct
21 Correct 287 ms 113484 KB Output is correct
22 Correct 164 ms 100584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 28 ms 54376 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 29 ms 54444 KB Output is correct
5 Correct 30 ms 54320 KB Output is correct
6 Correct 30 ms 54424 KB Output is correct
7 Correct 31 ms 54452 KB Output is correct
8 Correct 30 ms 54392 KB Output is correct
9 Correct 30 ms 54456 KB Output is correct
10 Correct 35 ms 54396 KB Output is correct
11 Correct 33 ms 54356 KB Output is correct
12 Correct 35 ms 54348 KB Output is correct
13 Correct 30 ms 54356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 28 ms 54376 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 29 ms 54444 KB Output is correct
5 Correct 30 ms 54320 KB Output is correct
6 Correct 30 ms 54424 KB Output is correct
7 Correct 31 ms 54452 KB Output is correct
8 Correct 30 ms 54392 KB Output is correct
9 Correct 30 ms 54456 KB Output is correct
10 Correct 35 ms 54396 KB Output is correct
11 Correct 33 ms 54356 KB Output is correct
12 Correct 35 ms 54348 KB Output is correct
13 Correct 30 ms 54356 KB Output is correct
14 Correct 29 ms 54348 KB Output is correct
15 Correct 28 ms 54296 KB Output is correct
16 Correct 31 ms 54408 KB Output is correct
17 Correct 31 ms 54360 KB Output is correct
18 Correct 30 ms 54404 KB Output is correct
19 Correct 28 ms 54396 KB Output is correct
20 Correct 31 ms 54480 KB Output is correct
21 Correct 34 ms 54432 KB Output is correct
22 Correct 29 ms 54400 KB Output is correct
23 Correct 28 ms 54356 KB Output is correct
24 Correct 28 ms 54428 KB Output is correct
25 Correct 30 ms 54476 KB Output is correct
26 Correct 30 ms 54440 KB Output is correct
27 Correct 32 ms 54388 KB Output is correct
28 Correct 28 ms 54356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 28 ms 54376 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 29 ms 54444 KB Output is correct
5 Correct 30 ms 54320 KB Output is correct
6 Correct 30 ms 54424 KB Output is correct
7 Correct 31 ms 54452 KB Output is correct
8 Correct 30 ms 54392 KB Output is correct
9 Correct 30 ms 54456 KB Output is correct
10 Correct 35 ms 54396 KB Output is correct
11 Correct 33 ms 54356 KB Output is correct
12 Correct 35 ms 54348 KB Output is correct
13 Correct 30 ms 54356 KB Output is correct
14 Correct 29 ms 54348 KB Output is correct
15 Correct 28 ms 54296 KB Output is correct
16 Correct 31 ms 54408 KB Output is correct
17 Correct 31 ms 54360 KB Output is correct
18 Correct 30 ms 54404 KB Output is correct
19 Correct 28 ms 54396 KB Output is correct
20 Correct 31 ms 54480 KB Output is correct
21 Correct 34 ms 54432 KB Output is correct
22 Correct 29 ms 54400 KB Output is correct
23 Correct 28 ms 54356 KB Output is correct
24 Correct 28 ms 54428 KB Output is correct
25 Correct 30 ms 54476 KB Output is correct
26 Correct 30 ms 54440 KB Output is correct
27 Correct 32 ms 54388 KB Output is correct
28 Correct 28 ms 54356 KB Output is correct
29 Correct 31 ms 54484 KB Output is correct
30 Correct 32 ms 54504 KB Output is correct
31 Correct 31 ms 54484 KB Output is correct
32 Correct 31 ms 54500 KB Output is correct
33 Correct 35 ms 54440 KB Output is correct
34 Correct 36 ms 54508 KB Output is correct
35 Correct 36 ms 54476 KB Output is correct
36 Correct 31 ms 54392 KB Output is correct
37 Correct 30 ms 54396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 28 ms 54376 KB Output is correct
3 Correct 34 ms 54356 KB Output is correct
4 Correct 29 ms 54444 KB Output is correct
5 Correct 30 ms 54320 KB Output is correct
6 Correct 30 ms 54424 KB Output is correct
7 Correct 31 ms 54452 KB Output is correct
8 Correct 30 ms 54392 KB Output is correct
9 Correct 30 ms 54456 KB Output is correct
10 Correct 35 ms 54396 KB Output is correct
11 Correct 33 ms 54356 KB Output is correct
12 Correct 35 ms 54348 KB Output is correct
13 Correct 30 ms 54356 KB Output is correct
14 Correct 29 ms 54348 KB Output is correct
15 Correct 28 ms 54296 KB Output is correct
16 Correct 31 ms 54408 KB Output is correct
17 Correct 31 ms 54360 KB Output is correct
18 Correct 30 ms 54404 KB Output is correct
19 Correct 28 ms 54396 KB Output is correct
20 Correct 31 ms 54480 KB Output is correct
21 Correct 34 ms 54432 KB Output is correct
22 Correct 29 ms 54400 KB Output is correct
23 Correct 28 ms 54356 KB Output is correct
24 Correct 28 ms 54428 KB Output is correct
25 Correct 30 ms 54476 KB Output is correct
26 Correct 30 ms 54440 KB Output is correct
27 Correct 32 ms 54388 KB Output is correct
28 Correct 28 ms 54356 KB Output is correct
29 Correct 31 ms 54484 KB Output is correct
30 Correct 32 ms 54504 KB Output is correct
31 Correct 31 ms 54484 KB Output is correct
32 Correct 31 ms 54500 KB Output is correct
33 Correct 35 ms 54440 KB Output is correct
34 Correct 36 ms 54508 KB Output is correct
35 Correct 36 ms 54476 KB Output is correct
36 Correct 31 ms 54392 KB Output is correct
37 Correct 30 ms 54396 KB Output is correct
38 Correct 83 ms 57748 KB Output is correct
39 Correct 78 ms 79172 KB Output is correct
40 Correct 94 ms 57600 KB Output is correct
41 Correct 108 ms 57532 KB Output is correct
42 Correct 82 ms 57436 KB Output is correct
43 Correct 79 ms 56900 KB Output is correct
44 Correct 48 ms 55076 KB Output is correct
45 Correct 105 ms 73408 KB Output is correct
46 Correct 109 ms 73420 KB Output is correct
47 Correct 85 ms 76308 KB Output is correct
48 Correct 86 ms 76260 KB Output is correct
49 Correct 93 ms 73460 KB Output is correct
50 Correct 97 ms 73564 KB Output is correct
51 Correct 80 ms 74764 KB Output is correct
52 Correct 89 ms 74500 KB Output is correct
53 Correct 48 ms 56360 KB Output is correct
54 Correct 122 ms 73324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54348 KB Output is correct
2 Correct 29 ms 54288 KB Output is correct
3 Correct 28 ms 54400 KB Output is correct
4 Correct 33 ms 54356 KB Output is correct
5 Correct 39 ms 54400 KB Output is correct
6 Correct 30 ms 54448 KB Output is correct
7 Correct 29 ms 54348 KB Output is correct
8 Correct 28 ms 54372 KB Output is correct
9 Correct 28 ms 54356 KB Output is correct
10 Correct 28 ms 54376 KB Output is correct
11 Correct 28 ms 54288 KB Output is correct
12 Correct 35 ms 54528 KB Output is correct
13 Correct 75 ms 54908 KB Output is correct
14 Correct 98 ms 55308 KB Output is correct
15 Correct 84 ms 55068 KB Output is correct
16 Correct 161 ms 78188 KB Output is correct
17 Correct 486 ms 101176 KB Output is correct
18 Correct 881 ms 125916 KB Output is correct
19 Correct 234 ms 83020 KB Output is correct
20 Correct 258 ms 83196 KB Output is correct
21 Correct 231 ms 83064 KB Output is correct
22 Correct 428 ms 99712 KB Output is correct
23 Correct 304 ms 99284 KB Output is correct
24 Correct 324 ms 99076 KB Output is correct
25 Correct 319 ms 98936 KB Output is correct
26 Correct 325 ms 99412 KB Output is correct
27 Correct 541 ms 114972 KB Output is correct
28 Correct 512 ms 116160 KB Output is correct
29 Correct 503 ms 113572 KB Output is correct
30 Correct 366 ms 101068 KB Output is correct
31 Correct 364 ms 101796 KB Output is correct
32 Correct 406 ms 100692 KB Output is correct
33 Correct 353 ms 101832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 54356 KB Output is correct
2 Correct 29 ms 54336 KB Output is correct
3 Correct 26 ms 54280 KB Output is correct
4 Correct 48 ms 54420 KB Output is correct
5 Correct 63 ms 54412 KB Output is correct
6 Correct 29 ms 54444 KB Output is correct
7 Correct 29 ms 54356 KB Output is correct
8 Correct 31 ms 54476 KB Output is correct
9 Correct 86 ms 56460 KB Output is correct
10 Correct 85 ms 77720 KB Output is correct
11 Correct 45 ms 54404 KB Output is correct
12 Correct 92 ms 54444 KB Output is correct
13 Correct 215 ms 102528 KB Output is correct
14 Correct 205 ms 99972 KB Output is correct
15 Correct 407 ms 105868 KB Output is correct
16 Correct 854 ms 140188 KB Output is correct
17 Correct 262 ms 111948 KB Output is correct
18 Correct 219 ms 116824 KB Output is correct
19 Correct 234 ms 109772 KB Output is correct
20 Correct 242 ms 109968 KB Output is correct
21 Correct 287 ms 113484 KB Output is correct
22 Correct 164 ms 100584 KB Output is correct
23 Correct 28 ms 54356 KB Output is correct
24 Correct 28 ms 54376 KB Output is correct
25 Correct 34 ms 54356 KB Output is correct
26 Correct 29 ms 54444 KB Output is correct
27 Correct 30 ms 54320 KB Output is correct
28 Correct 30 ms 54424 KB Output is correct
29 Correct 31 ms 54452 KB Output is correct
30 Correct 30 ms 54392 KB Output is correct
31 Correct 30 ms 54456 KB Output is correct
32 Correct 35 ms 54396 KB Output is correct
33 Correct 33 ms 54356 KB Output is correct
34 Correct 35 ms 54348 KB Output is correct
35 Correct 30 ms 54356 KB Output is correct
36 Correct 29 ms 54348 KB Output is correct
37 Correct 28 ms 54296 KB Output is correct
38 Correct 31 ms 54408 KB Output is correct
39 Correct 31 ms 54360 KB Output is correct
40 Correct 30 ms 54404 KB Output is correct
41 Correct 28 ms 54396 KB Output is correct
42 Correct 31 ms 54480 KB Output is correct
43 Correct 34 ms 54432 KB Output is correct
44 Correct 29 ms 54400 KB Output is correct
45 Correct 28 ms 54356 KB Output is correct
46 Correct 28 ms 54428 KB Output is correct
47 Correct 30 ms 54476 KB Output is correct
48 Correct 30 ms 54440 KB Output is correct
49 Correct 32 ms 54388 KB Output is correct
50 Correct 28 ms 54356 KB Output is correct
51 Correct 31 ms 54484 KB Output is correct
52 Correct 32 ms 54504 KB Output is correct
53 Correct 31 ms 54484 KB Output is correct
54 Correct 31 ms 54500 KB Output is correct
55 Correct 35 ms 54440 KB Output is correct
56 Correct 36 ms 54508 KB Output is correct
57 Correct 36 ms 54476 KB Output is correct
58 Correct 31 ms 54392 KB Output is correct
59 Correct 30 ms 54396 KB Output is correct
60 Correct 83 ms 57748 KB Output is correct
61 Correct 78 ms 79172 KB Output is correct
62 Correct 94 ms 57600 KB Output is correct
63 Correct 108 ms 57532 KB Output is correct
64 Correct 82 ms 57436 KB Output is correct
65 Correct 79 ms 56900 KB Output is correct
66 Correct 48 ms 55076 KB Output is correct
67 Correct 105 ms 73408 KB Output is correct
68 Correct 109 ms 73420 KB Output is correct
69 Correct 85 ms 76308 KB Output is correct
70 Correct 86 ms 76260 KB Output is correct
71 Correct 93 ms 73460 KB Output is correct
72 Correct 97 ms 73564 KB Output is correct
73 Correct 80 ms 74764 KB Output is correct
74 Correct 89 ms 74500 KB Output is correct
75 Correct 48 ms 56360 KB Output is correct
76 Correct 122 ms 73324 KB Output is correct
77 Correct 28 ms 54348 KB Output is correct
78 Correct 29 ms 54288 KB Output is correct
79 Correct 28 ms 54400 KB Output is correct
80 Correct 33 ms 54356 KB Output is correct
81 Correct 39 ms 54400 KB Output is correct
82 Correct 30 ms 54448 KB Output is correct
83 Correct 29 ms 54348 KB Output is correct
84 Correct 28 ms 54372 KB Output is correct
85 Correct 28 ms 54356 KB Output is correct
86 Correct 28 ms 54376 KB Output is correct
87 Correct 28 ms 54288 KB Output is correct
88 Correct 35 ms 54528 KB Output is correct
89 Correct 75 ms 54908 KB Output is correct
90 Correct 98 ms 55308 KB Output is correct
91 Correct 84 ms 55068 KB Output is correct
92 Correct 161 ms 78188 KB Output is correct
93 Correct 486 ms 101176 KB Output is correct
94 Correct 881 ms 125916 KB Output is correct
95 Correct 234 ms 83020 KB Output is correct
96 Correct 258 ms 83196 KB Output is correct
97 Correct 231 ms 83064 KB Output is correct
98 Correct 428 ms 99712 KB Output is correct
99 Correct 304 ms 99284 KB Output is correct
100 Correct 324 ms 99076 KB Output is correct
101 Correct 319 ms 98936 KB Output is correct
102 Correct 325 ms 99412 KB Output is correct
103 Correct 541 ms 114972 KB Output is correct
104 Correct 512 ms 116160 KB Output is correct
105 Correct 503 ms 113572 KB Output is correct
106 Correct 366 ms 101068 KB Output is correct
107 Correct 364 ms 101796 KB Output is correct
108 Correct 406 ms 100692 KB Output is correct
109 Correct 353 ms 101832 KB Output is correct
110 Correct 115 ms 55480 KB Output is correct
111 Correct 66 ms 55064 KB Output is correct
112 Correct 484 ms 109708 KB Output is correct
113 Correct 222 ms 87756 KB Output is correct
114 Correct 362 ms 103132 KB Output is correct
115 Correct 88 ms 74880 KB Output is correct
116 Correct 334 ms 96624 KB Output is correct
117 Correct 1122 ms 145164 KB Output is correct
118 Correct 137 ms 73400 KB Output is correct
119 Correct 125 ms 73400 KB Output is correct
120 Correct 45 ms 57940 KB Output is correct
121 Correct 396 ms 97880 KB Output is correct
122 Correct 415 ms 97868 KB Output is correct
123 Correct 213 ms 90488 KB Output is correct
124 Correct 248 ms 90612 KB Output is correct
125 Correct 225 ms 91852 KB Output is correct
126 Correct 828 ms 140676 KB Output is correct
127 Correct 340 ms 115076 KB Output is correct
128 Correct 272 ms 115792 KB Output is correct
129 Correct 268 ms 114560 KB Output is correct
130 Correct 285 ms 114932 KB Output is correct