이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using Rect = array<int, 4>;
const Rect FULL = {0, 0, INF, INF};
Rect inter(const Rect &l, const Rect &r) {
return {max(l[0], r[0]), max(l[1], r[1]), min(l[2], r[2]), min(l[3], r[3])};
}
mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());
int main() {
ios_base::sync_with_stdio(false);
int N, K;
cin >> N >> K;
vector<Rect> A(N), ans(K);
for (int i = 0; i < N; ++i) {
cin >> A[i][0] >> A[i][1] >> A[i][2] >> A[i][3];
}
while (true) {
vector<Rect> goods, bads;
for (int z = 0; z < K; ++z) ans[z] = FULL;
for (auto r : A) {
bool ok = false;
for (int z = 0; z < K; ++z) {
Rect nans = inter(ans[z], r);
if (nans[0] <= nans[2] && nans[1] <= nans[3]) {
ans[z] = nans;
goods.emplace_back(r);
ok = true;
break;
}
}
if (!ok) bads.emplace_back(r);
}
if (bads.empty()) break;
A = bads;
shuffle(A.begin(), A.end(), rng);
A.insert(A.end(), goods.begin(), goods.end());
}
for (int z = 0; z < K; ++z) {
cout << ans[z][0] << " " << ans[z][1] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |