This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 200000, X = 1000000000;
vector<array<int, 2>> ans;
array<int, 4> rect[N];
bool tested[N];
int n, k;
void print() {
while ((int) ans.size() < k) {
ans.push_back(ans.back());
}
for (auto [x, y] : ans) {
cout << x << " " << y << "\n";
}
exit(0);
}
void solve() {
if (count(tested, tested + n, false) == 0) {
while ((int) ans.size() < k) {
ans.push_back(ans.back());
}
for (auto [x, y] : ans) {
cout << x << " " << y << "\n";
}
exit(0);
} else if ((int) ans.size() == k) {
return;
}
int x1 = X, x2 = 0, y1 = X, y2 = 0;
for (int i = 0; i < n; ++i) {
auto [l, d, r, u] = rect[i];
if (!tested[i]) {
x1 = min(x1, r);
x2 = max(x2, l);
y1 = min(y1, u);
y2 = max(y2, d);
}
}
for (auto x : {x1, x2}) {
for (auto y : {y1, y2}) {
ans.push_back({x, y});
vector<int> undo;
for (int i = 0; i < n; ++i) {
auto [l, d, r, u] = rect[i];
if (!tested[i] && l <= x && x <= r && d <= y && y <= u) {
undo.push_back(i);
tested[i] = true;
}
}
solve();
for (auto i : undo) {
tested[i] = false;
}
ans.pop_back();
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 0; i < n; ++i) {
for (auto &j : rect[i]) {
cin >> j;
}
}
solve();
}
# | 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... |