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;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
const int mx = 200'000;
const int inf = 2'000'000'000;
int N, K;
vi X1, X2, Y1, Y2;
bool check(int x, int y, int r)
{
return X1[r] <= x && x <= X2[r] && Y1[r] <= y && y <= Y2[r];
}
bool check(vi x, vi y)
{
for(int i = 0; i < N; i++)
{
bool works = 0;
for(int j = 0; j < K; j++)
{
if(check(x[j], y[j], i))
works = 1;
}
if(!works)
return 0;
}
return 1;
}
void answer(vi x, vi y)
{
for(int k = 0; k < K; k++)
{
cout << x[k] << ' ' << y[k] << '\n';
}
}
int max(vi& A)
{
int res = -inf;
for(int a : A)
res = max(res, a);
return res;
}
int min(vi& A)
{
int res = inf;
for(int a : A)
res = min(res, a);
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N >> K;
X1 = X2 = Y1 = Y2 = vi(N);
for(int i = 0; i < N; i++)
{
cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
}
if(check({max(X1), min(X2)}, {max(Y1), min(Y2)}))
{
// cerr << "hello\n";
answer({max(X1), min(X2)}, {max(Y1), min(Y2)});
}
else
{
// cerr << "world\n";
answer({max(X1), min(X2)}, {min(Y2), max(Y1)});
}
}
# | 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... |