Submission #744039

# Submission time Handle Problem Language Result Execution time Memory
744039 2023-05-18T07:31:40 Z maomao90 Izvanzemaljci (COI21_izvanzemaljci) C++17
26 / 100
57 ms 10260 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 = 1000000005;
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 = 2 * 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 (mnto(cost, max(lft, rht))) {
                ans[0] = {pmxx[i] - lft, pmny[i], lft};
                ans[1] = {smnx[i + 1], smny[i + 1], rht};
            }
        }
        sort(xy, xy + n, [&] (ii l, ii r) {
                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 (mnto(cost, max(lft, rht))) {
                ans[0] = {pmnx[i], pmxy[i] - lft, 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;
    }
}

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();
    }
}

Compilation message

izvanzemaljci.cpp:155:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  155 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 21 ms 1868 KB Output is correct
8 Correct 25 ms 1828 KB Output is correct
9 Correct 21 ms 1760 KB Output is correct
10 Correct 21 ms 1820 KB Output is correct
11 Correct 20 ms 1812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 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 0 ms 340 KB Output is correct
10 Correct 38 ms 8012 KB Output is correct
11 Correct 40 ms 10132 KB Output is correct
12 Correct 40 ms 10060 KB Output is correct
13 Correct 45 ms 10068 KB Output is correct
14 Correct 44 ms 10084 KB Output is correct
15 Correct 43 ms 10260 KB Output is correct
16 Correct 41 ms 10168 KB Output is correct
17 Correct 35 ms 9168 KB Output is correct
18 Correct 35 ms 8988 KB Output is correct
19 Correct 33 ms 8224 KB Output is correct
20 Correct 37 ms 8816 KB Output is correct
21 Correct 57 ms 10060 KB Output is correct
22 Correct 39 ms 10060 KB Output is correct
23 Correct 39 ms 10124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 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 -