#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define ar array
const int mxN=2e5;
int n, k, d[mxN], b[mxN];
ar<int, 4> a[mxN], p[4];
ar<int, 4> ir{1, 1, INT_MAX, INT_MAX};
vector<int> v1, v2;
ar<int, 4> it(ar<int, 4> a, ar<int, 4> b) {
return {max(a[0], b[0]), max(a[1], b[1]), min(a[2], b[2]), min(a[3], b[3])};
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<long long>(L, R)(rng);
cin >> n >> k;
for(int i=0; i<n; ++i) {
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
v2.push_back(i);
}
while(1){
vector<int> u=v2;
v2.clear();
for(int i=0; i<k; ++i)
p[i]=ir;
for(int i=0; i<n; ++i) {
bool ok=0;
for(int j=0; j<k; ++j) {
ar<int, 4> bl=it(p[j], a[u[i]]);
if(bl[0]<=bl[2]&&bl[1]<=bl[3]) {
p[j]=bl;
v1.push_back(u[i]);
ok=1;
break;
}
}
if(!ok)
v2.push_back(u[i]);
}
if(v2.empty()) {
for(int j=0; j<k; ++j)
cout << p[j][0] << " " << p[j][1] << "\n";
break;
}
shuffle(all(v2),rng);
v2.insert(v2.end(), all(v1));
v1.clear();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
416 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
420 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
424 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
420 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
468 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
420 KB |
Output is correct |
38 |
Correct |
2 ms |
500 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
3 ms |
468 KB |
Output is correct |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
472 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
1 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
1 ms |
468 KB |
Output is correct |
47 |
Correct |
1 ms |
468 KB |
Output is correct |
48 |
Correct |
1 ms |
468 KB |
Output is correct |
49 |
Correct |
2 ms |
468 KB |
Output is correct |
50 |
Correct |
2 ms |
468 KB |
Output is correct |
51 |
Correct |
2 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
468 KB |
Output is correct |
53 |
Correct |
1 ms |
468 KB |
Output is correct |
54 |
Correct |
2 ms |
472 KB |
Output is correct |
55 |
Correct |
1 ms |
468 KB |
Output is correct |
56 |
Correct |
3 ms |
468 KB |
Output is correct |
57 |
Correct |
1 ms |
468 KB |
Output is correct |
58 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
87 ms |
20572 KB |
Output is correct |
6 |
Correct |
84 ms |
20532 KB |
Output is correct |
7 |
Correct |
81 ms |
20512 KB |
Output is correct |
8 |
Correct |
110 ms |
20524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
93 ms |
20496 KB |
Output is correct |
6 |
Correct |
97 ms |
20492 KB |
Output is correct |
7 |
Correct |
94 ms |
20500 KB |
Output is correct |
8 |
Correct |
93 ms |
20492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
88 ms |
20536 KB |
Output is correct |
14 |
Correct |
95 ms |
20432 KB |
Output is correct |
15 |
Correct |
88 ms |
20620 KB |
Output is correct |
16 |
Correct |
125 ms |
20416 KB |
Output is correct |
17 |
Correct |
85 ms |
20504 KB |
Output is correct |
18 |
Correct |
101 ms |
20512 KB |
Output is correct |
19 |
Correct |
91 ms |
20496 KB |
Output is correct |
20 |
Correct |
112 ms |
20444 KB |
Output is correct |
21 |
Correct |
89 ms |
20468 KB |
Output is correct |
22 |
Correct |
93 ms |
20492 KB |
Output is correct |
23 |
Correct |
87 ms |
20436 KB |
Output is correct |
24 |
Correct |
93 ms |
20536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
416 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
420 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
464 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
424 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
420 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
468 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
420 KB |
Output is correct |
38 |
Correct |
2 ms |
500 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
3 ms |
468 KB |
Output is correct |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
472 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
1 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
1 ms |
468 KB |
Output is correct |
47 |
Correct |
1 ms |
468 KB |
Output is correct |
48 |
Correct |
1 ms |
468 KB |
Output is correct |
49 |
Correct |
2 ms |
468 KB |
Output is correct |
50 |
Correct |
2 ms |
468 KB |
Output is correct |
51 |
Correct |
2 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
468 KB |
Output is correct |
53 |
Correct |
1 ms |
468 KB |
Output is correct |
54 |
Correct |
2 ms |
472 KB |
Output is correct |
55 |
Correct |
1 ms |
468 KB |
Output is correct |
56 |
Correct |
3 ms |
468 KB |
Output is correct |
57 |
Correct |
1 ms |
468 KB |
Output is correct |
58 |
Correct |
1 ms |
468 KB |
Output is correct |
59 |
Correct |
100 ms |
20528 KB |
Output is correct |
60 |
Correct |
100 ms |
20416 KB |
Output is correct |
61 |
Correct |
89 ms |
20444 KB |
Output is correct |
62 |
Correct |
90 ms |
20516 KB |
Output is correct |
63 |
Correct |
96 ms |
20528 KB |
Output is correct |
64 |
Correct |
95 ms |
20428 KB |
Output is correct |
65 |
Correct |
150 ms |
20472 KB |
Output is correct |
66 |
Correct |
147 ms |
20512 KB |
Output is correct |
67 |
Correct |
92 ms |
20484 KB |
Output is correct |
68 |
Correct |
160 ms |
20420 KB |
Output is correct |
69 |
Correct |
97 ms |
20436 KB |
Output is correct |
70 |
Correct |
126 ms |
20488 KB |
Output is correct |
71 |
Correct |
93 ms |
20540 KB |
Output is correct |
72 |
Correct |
131 ms |
20548 KB |
Output is correct |
73 |
Correct |
113 ms |
20532 KB |
Output is correct |
74 |
Correct |
100 ms |
20556 KB |
Output is correct |
75 |
Correct |
92 ms |
20528 KB |
Output is correct |
76 |
Correct |
119 ms |
20428 KB |
Output is correct |
77 |
Correct |
93 ms |
20536 KB |
Output is correct |
78 |
Correct |
121 ms |
20424 KB |
Output is correct |
79 |
Correct |
123 ms |
20432 KB |
Output is correct |
80 |
Correct |
114 ms |
20544 KB |
Output is correct |
81 |
Correct |
100 ms |
20524 KB |
Output is correct |
82 |
Correct |
107 ms |
20532 KB |
Output is correct |
83 |
Correct |
101 ms |
20544 KB |
Output is correct |
84 |
Correct |
100 ms |
20528 KB |
Output is correct |
85 |
Correct |
102 ms |
20516 KB |
Output is correct |
86 |
Correct |
169 ms |
20428 KB |
Output is correct |
87 |
Correct |
100 ms |
20416 KB |
Output is correct |
88 |
Correct |
98 ms |
20484 KB |
Output is correct |
89 |
Correct |
98 ms |
20532 KB |
Output is correct |
90 |
Correct |
101 ms |
20492 KB |
Output is correct |
91 |
Correct |
90 ms |
20448 KB |
Output is correct |
92 |
Correct |
89 ms |
20416 KB |
Output is correct |
93 |
Correct |
87 ms |
20528 KB |
Output is correct |
94 |
Correct |
113 ms |
20524 KB |
Output is correct |
95 |
Correct |
97 ms |
20496 KB |
Output is correct |
96 |
Correct |
108 ms |
20632 KB |
Output is correct |
97 |
Correct |
89 ms |
20532 KB |
Output is correct |
98 |
Correct |
107 ms |
20536 KB |
Output is correct |
99 |
Correct |
100 ms |
20528 KB |
Output is correct |
100 |
Correct |
106 ms |
20544 KB |
Output is correct |
101 |
Correct |
95 ms |
20492 KB |
Output is correct |
102 |
Correct |
98 ms |
20536 KB |
Output is correct |
103 |
Correct |
125 ms |
20500 KB |
Output is correct |
104 |
Correct |
105 ms |
20528 KB |
Output is correct |
105 |
Correct |
105 ms |
20508 KB |
Output is correct |
106 |
Correct |
94 ms |
20544 KB |
Output is correct |
107 |
Correct |
104 ms |
20512 KB |
Output is correct |
108 |
Correct |
94 ms |
20544 KB |
Output is correct |
109 |
Correct |
106 ms |
20512 KB |
Output is correct |
110 |
Correct |
112 ms |
20448 KB |
Output is correct |
111 |
Correct |
113 ms |
20436 KB |
Output is correct |
112 |
Correct |
103 ms |
20464 KB |
Output is correct |
113 |
Correct |
90 ms |
20672 KB |
Output is correct |
114 |
Correct |
97 ms |
20444 KB |
Output is correct |
115 |
Correct |
96 ms |
20492 KB |
Output is correct |
116 |
Correct |
95 ms |
20528 KB |
Output is correct |
117 |
Execution timed out |
3041 ms |
20628 KB |
Time limit exceeded |
118 |
Halted |
0 ms |
0 KB |
- |