Submission #1307749

#TimeUsernameProblemLanguageResultExecution timeMemory
1307749M_W_13Hamburg Steak (JOI20_hamburg)C++20
6 / 100
115 ms6700 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; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; prostokat T[n]; int X1[n]; int X2[n]; int Y1[n]; int Y2[n]; rep(i, n) { cin >> T[i].l >> T[i].d >> T[i].r >> T[i].u; X1[i] = T[i].l; X2[i] = T[i].r; Y1[i] = T[i].d; Y2[i] = T[i].u; } sort(X1, X1 + n); sort(X2, X2 + n); sort(Y1, Y1 + n); sort(Y2, Y2 + n); int val = 1e9 + 1; A.pb(X1[n - 1]); A.pb(X2[0]); B.pb(Y1[n - 1]); B.pb(Y2[0]); int szA = A.size(); int szB = B.size(); int r = szA * szB; int maks = 1 << r; rep(maska, maks) { bool czy[szA][szB]; int cnt[szA]; int cnt2[szB]; rep(i, szA) { cnt[i] = 0; } rep(i, szB) { cnt2[i] = 0; } int pom = maska; int s = 0; vector<pkt> vec; rep(i, r) { if ((pom % 2) == 1) { czy[i/szB][i % szB] = true; cnt[i/szB]++; cnt2[i % szB]++; vec.pb({A[i/szB], B[i % szB]}); s++; } else { czy[i/szB][i % szB] = false; } pom /= 2; } bool spr = true; if (s > k) spr = false; if (!spr) continue; bool czy2 = true; rep(i, n) { bool c = false; for (auto p: vec) { if (check(T[i], p)) { c = true; break; } } if (!c) czy2 = false; } if (czy2) { while ((int)vec.size() < k) { vec.pb(vec[0]); } for (auto p: vec) { cout << p.x << " " << p.y << '\n'; } break; } } 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...