답안 #216313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216313 2020-03-27T05:11:20 Z model_code 함박 스테이크 (JOI20_hamburg) C++17
100 / 100
1087 ms 32700 KB
#include <iostream>
#include <vector>
#include <array>
#include <tuple>
#include <algorithm>
#include <cassert>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0 ? 1 : 10 * TEN(n - 1)); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

const int INF = TEN(9) + TEN(8);

struct P {
    int x, y;
    bool operator<(P r) const {
        return tie(x, y) < tie(r.x, r.y);
    }

};

struct Rect {
    P ld, ru;
    bool inside(P p) const {
        return (ld.x <= p.x && p.x <= ru.x)
            && (ld.y <= p.y && p.y <= ru.y);
    }
};

V<Rect> filter(const V<Rect>& rects, P p) {
    V<Rect> v;
    for (auto rect: rects) {
        if (rect.inside(p)) continue;
        v.push_back(rect);
    }
    return v;
}

V<P> join(V<P> a, const V<P>& b) {
    for (auto p: b) a.push_back(p);
    return a;
}

bool inside(int a, int b, int c) { return b <= a && a <= c; }

struct SuperVector {
    V<P> ps;
    V<int> l_mi, l_ma, r_mi, r_ma;
    void init() {
        sort(ps.begin(), ps.end(), [&](P l, P r) {
            return l.x < r.x;
        });
        int n = int(ps.size());
        l_mi = l_ma = V<int>(n + 1);
        l_mi[0] = INF;
        l_ma[0] = -INF;
        for (int i = 0; i < n; i++) {
            l_mi[i + 1] = min(l_mi[i], ps[i].y);
            l_ma[i + 1] = max(l_ma[i], ps[i].y);
        }
        r_mi = r_ma = V<int>(n + 1);
        r_mi[n] = INF;
        r_ma[n] = -INF;
        for (int i = n - 1; i >= 0; i--) {
            r_mi[i] = min(r_mi[i + 1], ps[i].y);
            r_ma[i] = max(r_ma[i + 1], ps[i].y);
        }
    }

    int l_min(int x) {
        int idx = int(lower_bound(ps.begin(), ps.end(), P{x, -INF}) - ps.begin());
        return l_mi[idx];
    }
    int l_max(int x) {
        int idx = int(lower_bound(ps.begin(), ps.end(), P{x, -INF}) - ps.begin());
        return l_ma[idx];
    }

    int r_min(int x) {
        int idx = int(lower_bound(ps.begin(), ps.end(), P{x, INF}) - ps.begin());
        return r_mi[idx];
    }
    int r_max(int x) {
        int idx = int(lower_bound(ps.begin(), ps.end(), P{x, INF}) - ps.begin());
        return r_ma[idx];
    }
};

V<P> solve4_cross(V<Rect> rects) {
    int l = INF, d = INF, r = -INF, u = -INF;
    for (auto rect : rects) {
        l = min(l, rect.ru.x);
        d = min(d, rect.ru.y);
        r = max(r, rect.ld.x);
        u = max(u, rect.ld.y);
    }

    int l_min = d, l_max = u;
    int d_min = l, d_max = r;
    int r_min = d, r_max = u;
    int u_min = l, u_max = r;

    SuperVector lu, ur, rd, dl, lr, ud;
    for (auto rect : rects) {
        if (l < rect.ld.x && rect.ru.x < r) {
            if (d < rect.ld.y) {
                u_min = max(u_min, rect.ld.x);
                u_max = min(u_max, rect.ru.x);
                continue;
            }
            if (rect.ru.y < u) {
                d_min = max(d_min, rect.ld.x);
                d_max = min(d_max, rect.ru.x);
                continue;
            }
            u_max = min(u_max, rect.ru.x);
            d_min = max(d_min, rect.ld.x);
            ud.ps.push_back({rect.ld.x, rect.ru.x});
            continue;
        }
        if (d < rect.ld.y && rect.ru.y < u) {
            if (l < rect.ld.x) {
                r_min = max(r_min, rect.ld.y);
                r_max = min(r_max, rect.ru.y);
                continue;
            }
            if (rect.ru.x < r) {
                l_min = max(l_min, rect.ld.y);
                l_max = min(l_max, rect.ru.y);
                continue;
            }
            l_max = min(l_max, rect.ru.y);
            r_min = max(r_min, rect.ld.y);
            lr.ps.push_back({rect.ld.y, rect.ru.y});
            continue;
        }
        if (rect.ru.x < r && rect.ru.y < u) {
            dl.ps.push_back({rect.ru.x, rect.ru.y});
            continue;
        }
        if (rect.ru.x < r && d < rect.ld.y) {
            lu.ps.push_back({rect.ld.y, rect.ru.x});
            continue;
        }
        if (l < rect.ld.x && d < rect.ld.y) {
            ur.ps.push_back({rect.ld.x, rect.ld.y});
            continue;
        }
        if (l < rect.ld.x && rect.ru.y < u) {
            rd.ps.push_back({rect.ru.y, rect.ld.x});
            continue;
        }
    }
    lu.init(); ur.init(); rd.init(); dl.init(); lr.init(); ud.init();

    V<int> l_pred = {l_min, l_max};
    for (auto rect: rects) {
        l_pred.push_back(rect.ld.y);
        l_pred.push_back(rect.ru.y);
    }

    for (int _l : l_pred) {
        if (!inside(_l, l_min, l_max)) continue;
        int _u = min(u_max, lu.r_min(_l));
        if (_u < u_min) continue;
        int _r = max(r_min, ur.r_max(_u));
        if (min(lr.r_min(_l), r_max) < _r) continue;
        int _d = max(d_min, rd.l_max(_r));
        if (min(ud.r_min(_u), d_max) < _d) continue;
        if (dl.l_min(_d) < _l) continue;

        return {
            P{l, _l},
            P{_u, u},
            P{r, _r},
            P{_d, d},
        };
    }

    return {};
}

V<P> solve4_non_cross(V<Rect> rects) {
    int l = INF, d = INF, r = -INF, u = -INF;
    for (auto rect : rects) {
        l = min(l, rect.ru.x);
        d = min(d, rect.ru.y);
        r = max(r, rect.ld.x);
        u = max(u, rect.ld.y);
    }

    int l_min = d, l_max = u;
    int d_min = l, d_max = r;
    int r_min = d, r_max = u;
    int u_min = l, u_max = r;

    SuperVector ld, lu, du, dr, ur, lr;
    for (auto rect : rects) {
        if (l < rect.ld.x && rect.ru.x < r) {
            if (d < rect.ld.y) {
                u_min = max(u_min, rect.ld.x);
                u_max = min(u_max, rect.ru.x);
                continue;
            }
            if (rect.ru.y < u) {
                d_min = max(d_min, rect.ld.x);
                d_max = min(d_max, rect.ru.x);
                continue;
            }
            d_max = min(d_max, rect.ru.x);
            u_min = max(u_min, rect.ld.x);
            du.ps.push_back({rect.ld.x, rect.ru.x});
            continue;
        }
        if (d < rect.ld.y && rect.ru.y < u) {
            if (l < rect.ld.x) {
                r_min = max(r_min, rect.ld.y);
                r_max = min(r_max, rect.ru.y);
                continue;
            }
            if (rect.ru.x < r) {
                l_min = max(l_min, rect.ld.y);
                l_max = min(l_max, rect.ru.y);
                continue;
            }
            l_max = min(l_max, rect.ru.y);
            r_min = max(r_min, rect.ld.y);
            lr.ps.push_back({rect.ld.y, rect.ru.y});
            continue;
        }
        if (rect.ru.x < r && rect.ru.y < u) {
            ld.ps.push_back({rect.ru.y, rect.ru.x});
            continue;
        }
        if (rect.ru.x < r && d < rect.ld.y) {
            lu.ps.push_back({rect.ld.y, rect.ru.x});
            continue;
        }
        if (l < rect.ld.x && d < rect.ld.y) {
            ur.ps.push_back({rect.ld.x, rect.ld.y});
            continue;
        }
        if (l < rect.ld.x && rect.ru.y < u) {
            dr.ps.push_back({rect.ld.x, rect.ru.y});
            continue;
        }
    }
    ld.init(); lu.init(); du.init(); dr.init(); ur.init(); lr.init();

    V<int> l_pred = {l_min, l_max};
    for (auto rect : rects) {
        l_pred.push_back(rect.ld.y);
        l_pred.push_back(rect.ru.y);
    }

    for (int _l : l_pred) {
        if (!inside(_l, l_min, l_max)) continue;
        int _d = min(d_max, ld.l_min(_l)); 
        if (_d < d_min) continue;
        int _u = min({u_max, lu.r_min(_l), du.r_min(_d)});
        if (_u < u_min) continue;        
        int _r = min({r_max, dr.r_min(_d), lr.r_min(_l)});
        if (_r < max(r_min, ur.r_max(_u))) continue;
        return {
            P{l, _l},
            P{_u, u},
            P{r, _r},
            P{_d, d},
        };
    }

    return {};
}

V<P> solve(V<Rect> rects, int K) {
    assert(1 <= K && K <= 4);
    if (rects.empty()) return V<P>(K, P{1, 1});
    int l = INF, d = INF, r = -INF, u = -INF;
    for (auto rect : rects) {
        l = min(l, rect.ru.x);
        d = min(d, rect.ru.y);
        r = max(r, rect.ld.x);
        u = max(u, rect.ld.y);
    }
    for (auto x: {l, r}) {
        for (auto y: {d, u}) {
            P p = {x, y};
            auto nrects = filter(rects, p);
            if (K == 1) {
                if (nrects.empty()) return {p};
            } else {
                auto ans = solve(nrects, K - 1);
                if (!ans.empty()) return join(ans, {p});
            }
        }
    }

    if (K <= 3) return {};
    assert(K == 4);
    for (int ph = 0; ph < 2; ph++) {
        auto ans = solve4_cross(rects);
        if (!ans.empty()) {
            if (ph) {
                for (auto& p : ans) {
                    p.x *= -1;
                }
            }
            return ans;
        }
        for (auto& rect: rects) {
            swap(rect.ld.x, rect.ru.x);
            rect.ld.x *= -1;
            rect.ru.x *= -1;
        }
    }

    for (int ph = 0; ph < 2; ph++) {
        auto ans = solve4_non_cross(rects);
        if (!ans.empty()) {
            if (ph) {
                for (auto& p : ans) {
                    p.x *= -1;
                }
            }
            return ans;
        }
        for (auto& rect : rects) {
            swap(rect.ld.x, rect.ru.x);
            rect.ld.x *= -1;
            rect.ru.x *= -1;
        }
    }
    return {};
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    V<Rect> rects(n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d %d", &rects[i].ld.x, &rects[i].ld.y, &rects[i].ru.x, &rects[i].ru.y);
    }

    auto ans = solve(rects, k);

    assert(!ans.empty());
    for (auto p: ans) {
        printf("%d %d\n", p.x, p.y);
    }
    return 0;
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:342:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  342 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp:345:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  345 |         scanf("%d %d %d %d", &rects[i].ld.x, &rects[i].ld.y, &rects[i].ru.x, &rects[i].ru.y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 416 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 5 ms 608 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 4 ms 640 KB Output is correct
16 Correct 4 ms 640 KB Output is correct
17 Correct 6 ms 608 KB Output is correct
18 Correct 4 ms 640 KB Output is correct
19 Correct 5 ms 616 KB Output is correct
20 Correct 8 ms 640 KB Output is correct
21 Correct 6 ms 656 KB Output is correct
22 Correct 6 ms 624 KB Output is correct
23 Correct 7 ms 640 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 672 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 5 ms 564 KB Output is correct
32 Correct 4 ms 624 KB Output is correct
33 Correct 5 ms 608 KB Output is correct
34 Correct 6 ms 560 KB Output is correct
35 Correct 7 ms 652 KB Output is correct
36 Correct 5 ms 616 KB Output is correct
37 Correct 7 ms 652 KB Output is correct
38 Correct 10 ms 656 KB Output is correct
39 Correct 6 ms 640 KB Output is correct
40 Correct 6 ms 608 KB Output is correct
41 Correct 7 ms 616 KB Output is correct
42 Correct 6 ms 640 KB Output is correct
43 Correct 6 ms 648 KB Output is correct
44 Correct 6 ms 660 KB Output is correct
45 Correct 4 ms 560 KB Output is correct
46 Correct 7 ms 640 KB Output is correct
47 Correct 8 ms 640 KB Output is correct
48 Correct 7 ms 640 KB Output is correct
49 Correct 6 ms 644 KB Output is correct
50 Correct 6 ms 640 KB Output is correct
51 Correct 7 ms 640 KB Output is correct
52 Correct 6 ms 612 KB Output is correct
53 Correct 7 ms 640 KB Output is correct
54 Correct 7 ms 656 KB Output is correct
55 Correct 6 ms 576 KB Output is correct
56 Correct 4 ms 584 KB Output is correct
57 Correct 5 ms 556 KB Output is correct
58 Correct 5 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 136 ms 6576 KB Output is correct
6 Correct 134 ms 6648 KB Output is correct
7 Correct 136 ms 6520 KB Output is correct
8 Correct 192 ms 6520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 142 ms 9064 KB Output is correct
6 Correct 138 ms 8772 KB Output is correct
7 Correct 154 ms 9064 KB Output is correct
8 Correct 157 ms 17764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 416 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 137 ms 10088 KB Output is correct
14 Correct 166 ms 10344 KB Output is correct
15 Correct 141 ms 8876 KB Output is correct
16 Correct 152 ms 8940 KB Output is correct
17 Correct 152 ms 11432 KB Output is correct
18 Correct 141 ms 8812 KB Output is correct
19 Correct 155 ms 11880 KB Output is correct
20 Correct 148 ms 15464 KB Output is correct
21 Correct 306 ms 26132 KB Output is correct
22 Correct 196 ms 17152 KB Output is correct
23 Correct 181 ms 21912 KB Output is correct
24 Correct 202 ms 24688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 488 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 5 ms 608 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 4 ms 640 KB Output is correct
16 Correct 4 ms 640 KB Output is correct
17 Correct 6 ms 608 KB Output is correct
18 Correct 4 ms 640 KB Output is correct
19 Correct 5 ms 616 KB Output is correct
20 Correct 8 ms 640 KB Output is correct
21 Correct 6 ms 656 KB Output is correct
22 Correct 6 ms 624 KB Output is correct
23 Correct 7 ms 640 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 4 ms 672 KB Output is correct
27 Correct 4 ms 640 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 4 ms 640 KB Output is correct
31 Correct 5 ms 564 KB Output is correct
32 Correct 4 ms 624 KB Output is correct
33 Correct 5 ms 608 KB Output is correct
34 Correct 6 ms 560 KB Output is correct
35 Correct 7 ms 652 KB Output is correct
36 Correct 5 ms 616 KB Output is correct
37 Correct 7 ms 652 KB Output is correct
38 Correct 10 ms 656 KB Output is correct
39 Correct 6 ms 640 KB Output is correct
40 Correct 6 ms 608 KB Output is correct
41 Correct 7 ms 616 KB Output is correct
42 Correct 6 ms 640 KB Output is correct
43 Correct 6 ms 648 KB Output is correct
44 Correct 6 ms 660 KB Output is correct
45 Correct 4 ms 560 KB Output is correct
46 Correct 7 ms 640 KB Output is correct
47 Correct 8 ms 640 KB Output is correct
48 Correct 7 ms 640 KB Output is correct
49 Correct 6 ms 644 KB Output is correct
50 Correct 6 ms 640 KB Output is correct
51 Correct 7 ms 640 KB Output is correct
52 Correct 6 ms 612 KB Output is correct
53 Correct 7 ms 640 KB Output is correct
54 Correct 7 ms 656 KB Output is correct
55 Correct 6 ms 576 KB Output is correct
56 Correct 4 ms 584 KB Output is correct
57 Correct 5 ms 556 KB Output is correct
58 Correct 5 ms 564 KB Output is correct
59 Correct 171 ms 13864 KB Output is correct
60 Correct 165 ms 11168 KB Output is correct
61 Correct 140 ms 11808 KB Output is correct
62 Correct 157 ms 10656 KB Output is correct
63 Correct 148 ms 12260 KB Output is correct
64 Correct 158 ms 9516 KB Output is correct
65 Correct 141 ms 12840 KB Output is correct
66 Correct 158 ms 12264 KB Output is correct
67 Correct 272 ms 23180 KB Output is correct
68 Correct 197 ms 19520 KB Output is correct
69 Correct 171 ms 15720 KB Output is correct
70 Correct 188 ms 21988 KB Output is correct
71 Correct 808 ms 32372 KB Output is correct
72 Correct 840 ms 31012 KB Output is correct
73 Correct 722 ms 31692 KB Output is correct
74 Correct 539 ms 32564 KB Output is correct
75 Correct 471 ms 28576 KB Output is correct
76 Correct 468 ms 28356 KB Output is correct
77 Correct 602 ms 31608 KB Output is correct
78 Correct 1029 ms 30836 KB Output is correct
79 Correct 546 ms 28968 KB Output is correct
80 Correct 521 ms 29760 KB Output is correct
81 Correct 913 ms 29636 KB Output is correct
82 Correct 468 ms 26800 KB Output is correct
83 Correct 315 ms 29156 KB Output is correct
84 Correct 328 ms 19752 KB Output is correct
85 Correct 507 ms 31316 KB Output is correct
86 Correct 301 ms 26044 KB Output is correct
87 Correct 508 ms 32220 KB Output is correct
88 Correct 379 ms 30596 KB Output is correct
89 Correct 614 ms 27800 KB Output is correct
90 Correct 913 ms 30788 KB Output is correct
91 Correct 568 ms 26892 KB Output is correct
92 Correct 1087 ms 32700 KB Output is correct
93 Correct 781 ms 31492 KB Output is correct
94 Correct 884 ms 30420 KB Output is correct
95 Correct 854 ms 30396 KB Output is correct
96 Correct 707 ms 31168 KB Output is correct
97 Correct 843 ms 31760 KB Output is correct
98 Correct 733 ms 29840 KB Output is correct
99 Correct 600 ms 29836 KB Output is correct
100 Correct 909 ms 32440 KB Output is correct
101 Correct 883 ms 31836 KB Output is correct
102 Correct 503 ms 22132 KB Output is correct
103 Correct 1030 ms 32160 KB Output is correct
104 Correct 588 ms 26860 KB Output is correct
105 Correct 1042 ms 32608 KB Output is correct
106 Correct 909 ms 31832 KB Output is correct
107 Correct 746 ms 31548 KB Output is correct
108 Correct 974 ms 30744 KB Output is correct
109 Correct 1031 ms 30924 KB Output is correct
110 Correct 781 ms 31804 KB Output is correct
111 Correct 680 ms 29132 KB Output is correct
112 Correct 1006 ms 31916 KB Output is correct
113 Correct 401 ms 20652 KB Output is correct
114 Correct 405 ms 20600 KB Output is correct
115 Correct 399 ms 20628 KB Output is correct
116 Correct 399 ms 20892 KB Output is correct
117 Correct 558 ms 28620 KB Output is correct
118 Correct 553 ms 28588 KB Output is correct
119 Correct 544 ms 28556 KB Output is correct
120 Correct 538 ms 28536 KB Output is correct
121 Correct 553 ms 28592 KB Output is correct
122 Correct 568 ms 28692 KB Output is correct
123 Correct 553 ms 28508 KB Output is correct
124 Correct 563 ms 28512 KB Output is correct
125 Correct 559 ms 28540 KB Output is correct
126 Correct 548 ms 28608 KB Output is correct