Submission #1308130

#TimeUsernameProblemLanguageResultExecution timeMemory
1308130M_W_13Hamburg Steak (JOI20_hamburg)C++20
6 / 100
61 ms9708 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) a.begin(), a.end()
int N, k;
vector<int> A;
vector<int> B;


struct prostokat {
    int l, d, r, u;
};

struct pkt {
    int x, y;
};

bool check(prostokat p, pkt pt) {
    if (pt.x < p.l || pt.x > p.r) return false;
    if (pt.y < p.d || pt.y > p.u) return false;
    return true;
}

bool spr(vector<pkt> jakie, vector<prostokat> &T) {
    rep(i, N) {
        bool czy = false;
        for (auto p: jakie) {
            if (check(T[i], p)) {
                czy = true;
                break;
            }
        }
        if (!czy) return false;
    }
    return true;
}

pair<bool, vector<pkt>> solve2(vector<prostokat> T) {
    int n = (int)T.size();
    int X1[n];
    int X2[n];
    int Y1[n];
    int Y2[n];
    int minix = 1e9 + 1;
    int maksx = 0;
    int miniy = 1e9 + 1;
    int maksy = 0;
    rep(i, n) {
        X1[i] = T[i].l;
        X2[i] = T[i].r;
        Y1[i] = T[i].d;
        Y2[i] = T[i].u;
        minix = min(minix, X2[i]);
        maksx = max(maksx, X1[i]);
        miniy = min(miniy, Y2[i]);
        maksy = max(maksy, Y1[i]);
    }
    int val = 1e9 + 1;
    A.pb(minix);
    A.pb(maksx);
    B.pb(miniy);
    B.pb(maksy);
    int szA = A.size();
    int szB = B.size();
    int r = szA * szB;
    int maks = 1 << r;
    vector<pkt> pom;
    for (auto a: A) {
        for (auto b: B) {
            pom.pb({a, b});
        }
    }
    for (auto p: pom) {
        if (spr({p}, T)) {
            return {true, {p}};
        }
    }
    int sz = pom.size();
    rep(i, sz) {
        for (int j = i + 1; j < sz; j++) {
            pkt a = pom[i];
            pkt b = pom[j];
            if (spr({a, b}, T)) {
                return {true, {a, b}};
            }
        }
    }
    return {false, {}};
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> k;
    vector<prostokat> T;
    T.resize(N);
    rep(i, N) {
        cin >> T[i].l >> T[i].d >> T[i].r >> T[i].u;
    }
    pair<bool, vector<pkt>> para = solve2(T);
    for (auto p: para.nd) {
        cout << p.x << " " << p.y << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...