Submission #743989

# Submission time Handle Problem Language Result Execution time Memory
743989 2023-05-18T07:00:49 Z maomao90 Izvanzemaljci (COI21_izvanzemaljci) C++17
5 / 100
44 ms 8384 KB
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define int ll

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 2000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 100005;

int n, k;
ii xy[MAXN];

namespace st1 {
    int main() {
        int mnx = INF, mxx = -INF, mny = INF, mxy = -INF;
        REP (i, 0, n) {
            mnto(mnx, xy[i].FI);
            mxto(mxx, xy[i].FI);
            mnto(mny, xy[i].SE);
            mxto(mxy, xy[i].SE);
        }
        cout << mnx << ' ' << mny << ' ' << max({mxx - mnx, mxy - mny, 1ll}) << '\n';
        return 0;
    }
}
namespace st2 {
    int pmnx[MAXN], pmxx[MAXN], pmny[MAXN], pmxy[MAXN];
    int smnx[MAXN], smxx[MAXN], smny[MAXN], smxy[MAXN];
    iii ans[2];
    int main() {
        int cost = INF;
        sort(xy, xy + n);
        pmnx[0] = INF, pmxx[0] = -INF, pmny[0] = INF, pmxy[0] = -INF;
        REP (i, 0, n) {
            mnto(pmnx[i], xy[i].FI);
            mxto(pmxx[i], xy[i].FI);
            mnto(pmny[i], xy[i].SE);
            mxto(pmxy[i], xy[i].SE);
            pmnx[i + 1] = pmnx[i];
            pmxx[i + 1] = pmxx[i];
            pmny[i + 1] = pmny[i];
            pmxy[i + 1] = pmxy[i];
        }
        smnx[n] = INF, smxx[n] = -INF, smny[n] = INF, smxy[n] = -INF;
        RREP (i, n - 1, 0) {
            smnx[i] = smnx[i + 1];
            smxx[i] = smxx[i + 1];
            smny[i] = smny[i + 1];
            smxy[i] = smxy[i + 1];
            mnto(smnx[i], xy[i].FI);
            mxto(smxx[i], xy[i].FI);
            mnto(smny[i], xy[i].SE);
            mxto(smxy[i], xy[i].SE);
        }
        REP (i, 0, n - 1) {
            if (xy[i].FI == xy[i + 1].FI) {
                continue;
            }
            int lft = max({pmxx[i] - pmnx[i], pmxy[i] - pmny[i], 1ll}),
                rht = max({smxx[i + 1] - smnx[i + 1], smxy[i + 1] - smny[i + 1], 1ll});
            if (pmnx[i] + lft < smnx[i + 1] && mnto(cost, max(lft, rht))) {
                ans[0] = {pmnx[i], pmny[i], lft};
                ans[1] = {smnx[i + 1], smny[i + 1], rht};
            }
        }
        sort(xy, xy + n, [&] (ii l, ii r) {
                if (l.SE == r.SE) return l.FI < r.FI;
                return l.SE < r.SE;
                });
        pmnx[0] = INF, pmxx[0] = -INF, pmny[0] = INF, pmxy[0] = -INF;
        REP (i, 0, n) {
            mnto(pmnx[i], xy[i].FI);
            mxto(pmxx[i], xy[i].FI);
            mnto(pmny[i], xy[i].SE);
            mxto(pmxy[i], xy[i].SE);
            pmnx[i + 1] = pmnx[i];
            pmxx[i + 1] = pmxx[i];
            pmny[i + 1] = pmny[i];
            pmxy[i + 1] = pmxy[i];
        }
        smnx[n] = INF, smxx[n] = -INF, smny[n] = INF, smxy[n] = -INF;
        RREP (i, n - 1, 0) {
            smnx[i] = smnx[i + 1];
            smxx[i] = smxx[i + 1];
            smny[i] = smny[i + 1];
            smxy[i] = smxy[i + 1];
            mnto(smnx[i], xy[i].FI);
            mxto(smxx[i], xy[i].FI);
            mnto(smny[i], xy[i].SE);
            mxto(smxy[i], xy[i].SE);
        }
        REP (i, 0, n - 1) {
            if (xy[i].SE == xy[i + 1].SE) {
                continue;
            }
            int lft = max({pmxx[i] - pmnx[i], pmxy[i] - pmny[i], 1ll}),
                rht = max({smxx[i + 1] - smnx[i + 1], smxy[i + 1] - smny[i + 1], 1ll});
            if (pmny[i] + lft < smny[i + 1] && mnto(cost, max(lft, rht))) {
                ans[0] = {pmnx[i], pmny[i], lft};
                ans[1] = {smnx[i + 1], smny[i + 1], rht};
            }
        }
        int mnx = INF, mxx = -INF, mny = INF, mxy = -INF;
        REP (i, 0, n) {
            mnto(mnx, xy[i].FI);
            mxto(mxx, xy[i].FI);
            mnto(mny, xy[i].SE);
            mxto(mxy, xy[i].SE);
        }
        int l = max({mxx - mnx, mxy - mny, 1ll});
        if (mnto(cost, l)) {
            ans[0] = {mnx, mny, l};
            ans[1] = {INF, INF, 1};
        }
        REP (z, 0, 2) {
            auto [a, b, c] = ans[z];
            cout << a << ' ' << b << ' ' << c << '\n';
        }
        auto [a, b, c] = ans[0];
        auto [x, y, z] = ans[1];
        assert(a + c < x || x + z < a || b + c < y || y + z < b);
        return 0;
    }
}

signed main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n >> k;
    REP (i, 0, n) {
        cin >> xy[i].FI >> xy[i].SE;
    }
    if (k == 1) {
        return st1::main();
    } else if (k == 2) {
        return st2::main();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 27 ms 2324 KB Output is correct
8 Correct 26 ms 2348 KB Output is correct
9 Correct 26 ms 2356 KB Output is correct
10 Correct 24 ms 2352 KB Output is correct
11 Correct 34 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 44 ms 8384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -