#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define X first
#define Y second
const int N = 2e5 + 5;
typedef pair<int,int> ii;
struct Rec {
int l, r;
int u, d;
} a[N];
Rec p[4];
Rec inf;
Rec operator & (const Rec&a,const Rec&b) {
Rec c;
c.l = max(a.l,b.l);
c.u = max(a.u,b.u);
c.r = min(a.r,b.r);
c.d = min(a.d,b.d);
return c;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
srand(time(NULL));
int n; cin >> n;
int k; cin >> k;
inf.l = inf.u = 1;
inf.r = inf.d = 1e9 + 7;
vector<int> vec;
for(int i = 0 ; i < n ; ++i) {
cin >> a[i].l >> a[i].u;
cin >> a[i].r >> a[i].d;
vec.push_back(1);
}
while (1) {
vector<int> nxt = vec; vec.clear();
random_shuffle(all(nxt));
fill(p,p + k,inf);
for(int i : nxt) {
bool ok = 0;
for(int j = 0 ; j < k ; ++j) {
Rec T = p[j] & a[i];
if (T.l > T.r) continue;
if (T.u > T.d) continue;
p[j] = T;
ok = 1;
break;
}
if(!ok) {
vec = nxt;
break;
}
}
if (vec.empty()) {
for(int i = 0 ; i < k ; ++i)
cout << p[i].l << " " << p[i].u << "\n";
return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |