Submission #961707

#TimeUsernameProblemLanguageResultExecution timeMemory
961707Vladth11Hamburg Steak (JOI20_hamburg)C++14
15 / 100
143 ms16144 KiB
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize ("Ofast") #pragma GCC target ("avx2") #define int ll using namespace std; typedef long long ll; typedef pair <ll, ll> pii; const ll NMAX = 200001; const ll INF = 1e9; const ll nrbits = 20; const ll MOD = 998244353; struct rect { int x1, y1, x2, y2; } v[NMAX]; int n, k; vector <pii> sol; int taken[NMAX]; rect intersect(rect a, rect b) { rect sol = {max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2)}; return sol; } bool isIn(pii a, rect r) { return (r.x1 <= a.first && a.first <= r.x2 && r.y1 <= a.second && a.second <= r.y2); } rect solve1() { int i; rect sol = {0, 0, INF, INF}; for(i = 1; i <= n; i++) { sol = intersect(sol, v[i]); } return sol; } void afiseaza() { for(auto x : sol) { cout << x.first << " " << x.second << "\n"; } k -= sol.size(); while(k--) { cout << "0 0\n"; } exit(0); } void tryy(int lvl) { int i; if(lvl == 0) { int ok = 1; for(i = 1; i <= n; i++) { ok &= (taken[i] > 0); /// hai ca e bine daca e } if(ok) { afiseaza(); } return; } int xmin = INF, xmax = 0, ymin = INF, ymax = 0; for(i = 1; i <= n; i++) { if(taken[i]) continue; xmin = min(xmin, v[i].x2); xmax = max(xmax, v[i].x1); ymin = min(ymin, v[i].y2); ymax = max(ymax, v[i].y1); } vector <pii> per; per.push_back({xmin, ymin}); per.push_back({xmin, ymax}); per.push_back({xmax, ymin}); per.push_back({xmax, ymax}); for(int d = 0; d < 4; d++) { pii acum = per[d]; for(i = 1; i <= n; i++) { if(isIn(acum, v[i])) { taken[i]++; } } sol.push_back(acum); tryy(lvl - 1); for(i = 1; i <= n; i++) { if(isIn(acum, v[i])) taken[i]--; } sol.pop_back(); } } signed main() { #ifdef HOME ifstream cin(".in"); ofstream cout(".out"); #endif // HOME ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i; cin >> n >> k; for(i = 1; i <= n; i++) { cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2; /// it doesn't matter } /// K = 1? tryy(1); /// K = 2? tryy(2); /// K = 3? tryy(3); /// K = 4 and pair found tryy(4); 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...