# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258773 | Kastanda | Hamburg Steak (JOI20_hamburg) | C++11 | 3093 ms | 6620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// M
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
struct Data {int a, b, c, d;};
int n, k, M[N];;
Data A[N];
mt19937 Rnd(time(0));
inline Data Merge(Data X, Data Y)
{
Data R;
R.a = max(X.a, Y.a);
R.b = max(X.b, Y.b);
R.c = min(X.c, Y.c);
R.d = min(X.d, Y.d);
return R;
}
inline bool OK(Data X)
{
return (X.a <= X.c && X.b <= X.d);
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i ++)
scanf("%d%d%d%d", &A[i].a, &A[i].b, &A[i].c, &A[i].d);
vector < int > Priority;
while (true)
{
// May God help us ...
vector < int > P;
memset(M, 0, sizeof(M));
for (int i : Priority)
M[i] = 1, P.push_back(i);
shuffle(P.begin(), P.end(), Rnd);
for (int i = 1; i <= n; i ++)
if (!M[i]) P.push_back(i);
shuffle(P.begin() + (int)Priority.size(), P.end(), Rnd);
Priority.clear();
Data F[4];
for (int j = 0; j < k; j ++)
F[j].a = F[j].b = 0, F[j].c = F[j].d = 1e9 + 9;
for (int i : P)
{
bool Fail = 1;
for (int j = 0; j < k && Fail; j ++)
if (OK(Merge(A[i], F[j])))
F[j] = Merge(A[i], F[j]), Fail = 0;
if (Fail)
Priority.push_back(i);
}
if (!Priority.size())
{
for (int j = 0; j < k; j ++)
printf("%d %d\n", F[j].a, F[j].b);
return 0;
}
}
}
Compilation message (stderr)
# | 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... |