#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
const int INF = (int) 1e9;
struct Rect {
int x1, y1, x2, y2;
Rect(int _x1 = 1, int _y1 = 1, int _x2 = INF, int _y2 = INF) : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
bool ok() {
return x1 <= x2 && y1 <= y2;
}
};
inline Rect inter(Rect a, Rect b) {
return Rect(max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2));
}
int main() {
#ifdef HOME
ifstream cin("A.in");
ofstream cout("A.out");
#endif
int i, n, k;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
vector<Rect> r(n);
for(i = 0; i < n; i++) {
cin >> r[i].x1 >> r[i].y1 >> r[i].x2 >> r[i].y2;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<bool> vis(n);
while(true) {
vector<Rect> sol(k), new_r;
fill(vis.begin(), vis.end(), 0);
bool bad = 0;
for(i = 0; i < n; i++) {
bad = 1;
for(int j = 0; j < k; j++) {
if(inter(sol[j], r[i]).ok()) {
sol[j] = inter(sol[j], r[i]);
bad = 0;
break;
}
}
if(bad == 1) {
new_r.push_back(r[i]);
vis[i] = 1;
}
}
if(new_r.size() == 0) {
for(i = 0; i < k; i++) {
cout << sol[i].x1 << " " << sol[i].y1 << "\n";
}
return 0;
}
shuffle(new_r.begin(), new_r.end(), rng);
for(i = 0; i < n; i++) {
if(vis[i] == 0) {
new_r.push_back(r[i]);
}
}
swap(r, new_r);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
416 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
416 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
5 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
2 ms |
512 KB |
Output is correct |
34 |
Correct |
3 ms |
512 KB |
Output is correct |
35 |
Correct |
2 ms |
512 KB |
Output is correct |
36 |
Correct |
2 ms |
512 KB |
Output is correct |
37 |
Correct |
2 ms |
512 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
512 KB |
Output is correct |
40 |
Correct |
2 ms |
512 KB |
Output is correct |
41 |
Correct |
4 ms |
512 KB |
Output is correct |
42 |
Correct |
2 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
512 KB |
Output is correct |
44 |
Correct |
2 ms |
512 KB |
Output is correct |
45 |
Correct |
2 ms |
512 KB |
Output is correct |
46 |
Correct |
2 ms |
512 KB |
Output is correct |
47 |
Correct |
2 ms |
512 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
2 ms |
512 KB |
Output is correct |
50 |
Correct |
3 ms |
512 KB |
Output is correct |
51 |
Correct |
3 ms |
512 KB |
Output is correct |
52 |
Correct |
2 ms |
512 KB |
Output is correct |
53 |
Correct |
2 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
3 ms |
432 KB |
Output is correct |
56 |
Correct |
2 ms |
512 KB |
Output is correct |
57 |
Correct |
2 ms |
512 KB |
Output is correct |
58 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
105 ms |
3532 KB |
Output is correct |
6 |
Correct |
95 ms |
3456 KB |
Output is correct |
7 |
Correct |
95 ms |
3456 KB |
Output is correct |
8 |
Correct |
97 ms |
3528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
113 ms |
7740 KB |
Output is correct |
6 |
Correct |
106 ms |
7788 KB |
Output is correct |
7 |
Correct |
104 ms |
7736 KB |
Output is correct |
8 |
Correct |
109 ms |
7788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
115 ms |
10748 KB |
Output is correct |
14 |
Correct |
113 ms |
10748 KB |
Output is correct |
15 |
Correct |
117 ms |
10756 KB |
Output is correct |
16 |
Correct |
113 ms |
7792 KB |
Output is correct |
17 |
Correct |
108 ms |
7748 KB |
Output is correct |
18 |
Correct |
104 ms |
7748 KB |
Output is correct |
19 |
Correct |
123 ms |
7788 KB |
Output is correct |
20 |
Correct |
112 ms |
7788 KB |
Output is correct |
21 |
Correct |
110 ms |
7788 KB |
Output is correct |
22 |
Correct |
113 ms |
7792 KB |
Output is correct |
23 |
Correct |
114 ms |
10776 KB |
Output is correct |
24 |
Correct |
103 ms |
7740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
416 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
416 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
5 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
2 ms |
512 KB |
Output is correct |
34 |
Correct |
3 ms |
512 KB |
Output is correct |
35 |
Correct |
2 ms |
512 KB |
Output is correct |
36 |
Correct |
2 ms |
512 KB |
Output is correct |
37 |
Correct |
2 ms |
512 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
512 KB |
Output is correct |
40 |
Correct |
2 ms |
512 KB |
Output is correct |
41 |
Correct |
4 ms |
512 KB |
Output is correct |
42 |
Correct |
2 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
512 KB |
Output is correct |
44 |
Correct |
2 ms |
512 KB |
Output is correct |
45 |
Correct |
2 ms |
512 KB |
Output is correct |
46 |
Correct |
2 ms |
512 KB |
Output is correct |
47 |
Correct |
2 ms |
512 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
2 ms |
512 KB |
Output is correct |
50 |
Correct |
3 ms |
512 KB |
Output is correct |
51 |
Correct |
3 ms |
512 KB |
Output is correct |
52 |
Correct |
2 ms |
512 KB |
Output is correct |
53 |
Correct |
2 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
3 ms |
432 KB |
Output is correct |
56 |
Correct |
2 ms |
512 KB |
Output is correct |
57 |
Correct |
2 ms |
512 KB |
Output is correct |
58 |
Correct |
1 ms |
384 KB |
Output is correct |
59 |
Correct |
141 ms |
10824 KB |
Output is correct |
60 |
Correct |
115 ms |
7788 KB |
Output is correct |
61 |
Correct |
105 ms |
7740 KB |
Output is correct |
62 |
Correct |
118 ms |
7792 KB |
Output is correct |
63 |
Correct |
128 ms |
10752 KB |
Output is correct |
64 |
Correct |
119 ms |
10816 KB |
Output is correct |
65 |
Correct |
112 ms |
10744 KB |
Output is correct |
66 |
Correct |
103 ms |
7748 KB |
Output is correct |
67 |
Correct |
129 ms |
7788 KB |
Output is correct |
68 |
Correct |
118 ms |
10824 KB |
Output is correct |
69 |
Correct |
145 ms |
10748 KB |
Output is correct |
70 |
Correct |
145 ms |
10752 KB |
Output is correct |
71 |
Correct |
109 ms |
7744 KB |
Output is correct |
72 |
Correct |
121 ms |
10824 KB |
Output is correct |
73 |
Correct |
117 ms |
10756 KB |
Output is correct |
74 |
Correct |
114 ms |
7788 KB |
Output is correct |
75 |
Correct |
108 ms |
10800 KB |
Output is correct |
76 |
Correct |
117 ms |
10832 KB |
Output is correct |
77 |
Correct |
121 ms |
10824 KB |
Output is correct |
78 |
Correct |
128 ms |
10804 KB |
Output is correct |
79 |
Correct |
125 ms |
10760 KB |
Output is correct |
80 |
Correct |
119 ms |
10888 KB |
Output is correct |
81 |
Correct |
132 ms |
10756 KB |
Output is correct |
82 |
Correct |
114 ms |
10804 KB |
Output is correct |
83 |
Correct |
130 ms |
10816 KB |
Output is correct |
84 |
Correct |
121 ms |
10800 KB |
Output is correct |
85 |
Correct |
160 ms |
10804 KB |
Output is correct |
86 |
Correct |
142 ms |
10776 KB |
Output is correct |
87 |
Correct |
124 ms |
10800 KB |
Output is correct |
88 |
Correct |
125 ms |
10804 KB |
Output is correct |
89 |
Correct |
120 ms |
10876 KB |
Output is correct |
90 |
Correct |
124 ms |
10804 KB |
Output is correct |
91 |
Correct |
150 ms |
10816 KB |
Output is correct |
92 |
Correct |
141 ms |
10824 KB |
Output is correct |
93 |
Correct |
115 ms |
7788 KB |
Output is correct |
94 |
Correct |
124 ms |
10816 KB |
Output is correct |
95 |
Correct |
128 ms |
10824 KB |
Output is correct |
96 |
Correct |
126 ms |
10800 KB |
Output is correct |
97 |
Correct |
115 ms |
10676 KB |
Output is correct |
98 |
Correct |
105 ms |
7740 KB |
Output is correct |
99 |
Correct |
136 ms |
10812 KB |
Output is correct |
100 |
Correct |
138 ms |
10772 KB |
Output is correct |
101 |
Correct |
103 ms |
7740 KB |
Output is correct |
102 |
Correct |
123 ms |
10768 KB |
Output is correct |
103 |
Correct |
110 ms |
7788 KB |
Output is correct |
104 |
Correct |
116 ms |
11088 KB |
Output is correct |
105 |
Correct |
124 ms |
10832 KB |
Output is correct |
106 |
Correct |
115 ms |
10756 KB |
Output is correct |
107 |
Correct |
137 ms |
10768 KB |
Output is correct |
108 |
Correct |
110 ms |
7788 KB |
Output is correct |
109 |
Correct |
158 ms |
10776 KB |
Output is correct |
110 |
Correct |
111 ms |
10800 KB |
Output is correct |
111 |
Correct |
136 ms |
10832 KB |
Output is correct |
112 |
Correct |
133 ms |
10800 KB |
Output is correct |
113 |
Correct |
121 ms |
7788 KB |
Output is correct |
114 |
Correct |
113 ms |
7788 KB |
Output is correct |
115 |
Correct |
104 ms |
7788 KB |
Output is correct |
116 |
Correct |
137 ms |
7736 KB |
Output is correct |
117 |
Execution timed out |
3094 ms |
10816 KB |
Time limit exceeded |
118 |
Halted |
0 ms |
0 KB |
- |