답안 #998076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998076 2024-06-13T09:22:02 Z piOOE Izvanzemaljci (COI21_izvanzemaljci) C++17
26 / 100
34 ms 3576 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Answer {
    int ans = 2e9 + 7;
    vector<vector<ll>> res;

    void norm(int k) {
        int t = 0;
        ll x = 2.5e9, y = 2.5e9;
        while (res.size() < k) {
            res.push_back({x, y, 1});
            t += 1;
            if (t & 1) {
                x = -x;
            }
            if (t & 2) {
                y = -y;
            }
        }
    }
};

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

    int n, k;
    cin >> n >> k;

    vector<pair<ll, ll>> a(n);
    for (auto &[x, y] : a) {
        cin >> x >> y;
    }

    Answer ans{};
    ans.ans = 2e9 + 7;

    if (k >= 1) {
        ll minx = 2e9, maxx = -2e9, miny = 2e9, maxy = -2e9;
        for (auto &[x, y] : a) {
            minx = min(minx, x);
            maxx = max(maxx, x);
            miny = min(miny, y);
            maxy = max(maxy, y);
        }
        ll d = max({1LL, maxy - miny, maxx - minx});
        ans.ans = d;
        ans.res = {vector<ll>{minx, miny, d}};
    }

    if (k >= 2) {
        for (int t = 0; t < 2; ++t) {
            Answer now{};
            sort(a.begin(), a.end());
            vector<ll> mn(n + 1, 2e9), mx(n + 1, -2e9);
            for (int i = n - 1; i >= 0; --i) {
                mn[i] = min(mn[i + 1], a[i].second);
                mx[i] = max(mx[i + 1], a[i].second);
            }
            ll mny = 2e9, mxy = -2e9;
            for (int i = 0; i < n; ++i) {
                mny = min(mny, a[i].second);
                mxy = max(mxy, a[i].second);
                if (i + 1 < n && a[i + 1].first != a[i].first) {
                   ll d = max({1LL, mxy - mny, mx[i + 1] - mn[i + 1], a[i].first - a[0].first, a.back().first - a[i + 1].first});
                   if (now.ans > d) {
                       now.ans = d;
                       now.res.clear();
                       int rx = a[i].first;
                       int ry = mxy;
                       now.res.push_back({rx - d, ry - d, d});
                       int lx = a[i + 1].first;
                       int ly = mn[i + 1];
                       now.res.push_back({lx, ly, d});
                   }
                }
            }
            if (t == 1) {
                for (auto &f : now.res) {
                    swap(f[0], f[1]);
                }
            }
            if (ans.ans > now.ans) {
                ans = now;
            }
            for (auto &[x, y]: a) {
                swap(x, y);
            }
        }
    }

    ans.norm(k);

    for (auto &t : ans.res) {
        for (auto x : t) {
            cout << x << " ";
        }
        cout << '\n';
    }

    return 0;
}

Compilation message

izvanzemaljci.cpp: In member function 'void Answer::norm(int)':
izvanzemaljci.cpp:13:27: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |         while (res.size() < k) {
      |                ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 15 ms 1884 KB Output is correct
8 Correct 15 ms 1884 KB Output is correct
9 Correct 14 ms 1880 KB Output is correct
10 Correct 15 ms 1884 KB Output is correct
11 Correct 15 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 34 ms 3560 KB Output is correct
11 Correct 31 ms 3416 KB Output is correct
12 Correct 29 ms 3408 KB Output is correct
13 Correct 30 ms 3408 KB Output is correct
14 Correct 30 ms 3420 KB Output is correct
15 Correct 31 ms 3572 KB Output is correct
16 Correct 32 ms 3408 KB Output is correct
17 Correct 27 ms 3268 KB Output is correct
18 Correct 28 ms 3152 KB Output is correct
19 Correct 24 ms 2908 KB Output is correct
20 Correct 27 ms 3160 KB Output is correct
21 Correct 34 ms 3412 KB Output is correct
22 Correct 31 ms 3576 KB Output is correct
23 Correct 34 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -