Submission #213402

#TimeUsernameProblemLanguageResultExecution timeMemory
213402popovicirobertHamburg Steak (JOI20_hamburg)C++14
2 / 100
130 ms3456 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define uint unsigned int using namespace std; const int INF = (int) 1e9; struct Rect { int x1, y1, x2, y2; Rect(int _x1 = 1, int _y1 = 1, int _x2 = INF, int _y2 = INF) : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {} bool ok() { return x1 <= x2 && y1 <= y2; } }; inline Rect inter(Rect a, Rect b) { return Rect(max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2)); } int main() { #ifdef HOME ifstream cin("A.in"); ofstream cout("A.out"); #endif int i, n, k; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> k; vector<Rect> r(n); for(i = 0; i < n; i++) { cin >> r[i].x1 >> r[i].y1 >> r[i].x2 >> r[i].y2; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<bool> vis; while(true) { vector<Rect> sol(k), new_r; fill(vis.begin(), vis.end(), 0); bool bad = 0; for(i = 0; i < n; i++) { bad = 1; for(int j = 0; j < k; j++) { if(inter(sol[j], r[i]).ok()) { sol[j] = inter(sol[j], r[i]); bad = 0; break; } } if(bad == 1) { new_r.push_back(r[i]); vis[i] = 1; } } if(new_r.size() == 0) { for(i = 0; i < k; i++) { cout << sol[i].x1 << " " << sol[i].y1 << "\n"; } return 0; } shuffle(new_r.begin(), new_r.end(), rng); for(i = 0; i < n; i++) { if(vis[i] == 0) { new_r.push_back(r[i]); } } swap(r, new_r); } 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...