# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
787418 |
2023-07-19T07:16:10 Z |
박상훈(#10032) |
함박 스테이크 (JOI20_hamburg) |
C++17 |
|
3000 ms |
40344 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int INF = 1e9 + 100;
struct Rect{
int x1, y1, x2, y2;
Rect(){}
Rect(int _x1, int _y1, int _x2, int _y2): x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
void read(){
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
}
bool in(int x, int y){
return x1 <= x && x <= x2 && y1 <= y && y <= y2;
}
};
vector<pair<int, int>> ans;
void solve(vector<Rect> V, int k){
if (k==0){
if (!V.empty()) return;
for (auto &[x, y]:ans) printf("%d %d\n", x, y);
exit(0);
}
int lx = INF, rx = -INF, ly = INF, ry = -INF;
for (auto &[x1, y1, x2, y2]:V){
lx = min(lx, x2);
rx = max(rx, x1);
ly = min(ly, y2);
ry = max(ry, y1);
}
if (V.empty()) lx = rx = ly = ry = 1;
vector<pair<int, int>> C = {{lx, ly}, {lx, ry}, {rx, ly}, {rx, ry}};
if (k==4){
vector<int> X = {-INF}, Y = {-INF};
for (auto &[x1, y1, x2, y2]:V){
X.push_back(x1);
X.push_back(x2);
Y.push_back(y1);
Y.push_back(y2);
}
sort(X.begin(), X.end());
X.erase(unique(X.begin(), X.end()), X.end());
sort(Y.begin(), Y.end());
Y.erase(unique(Y.begin(), Y.end()), Y.end());
vector<Rect> nV;
for (auto &[x1, y1, x2, y2]:V){
int i1 = lower_bound(Y.begin(), Y.end(), y1) - Y.begin();
int i2 = lower_bound(Y.begin(), Y.end(), y2) - Y.begin();
int j1 = lower_bound(Y.begin(), Y.end(), y1) - Y.begin();
int j2 = lower_bound(Y.begin(), Y.end(), y2) - Y.begin();
nV.emplace_back(j1, i1, j2, i2);
}
vector<int> sum(Y.size());
vector<array<int, 3>> FUCK;
for (auto &[x1, y1, x2, y2]:nV) if (X[x2] >= rx){
if (y2+1 < (int)sum.size()) sum[y2+1]--;
sum[y1]++;
}
for (int i=1;i<(int)sum.size();i++){
sum[i] += sum[i-1];
FUCK.push_back({sum[i], rx, Y[i]});
}
// sum.clear();
// sum.resize(Y.size());
// for (auto &[x1, y1, x2, y2]:nV) if (X[x1] <= lx){
// if (y2+1 < (int)sum.size()) sum[y2+1]--;
// sum[y1]++;
// }
// for (int i=1;i<(int)sum.size();i++){
// sum[i] += sum[i-1];
// FUCK.push_back({sum[i], lx, Y[i]});
// }
// sum.clear();
// sum.resize(X.size());
// for (auto &[x1, y1, x2, y2]:nV) if (Y[y2] >= ry){
// if (x2+1 < (int)sum.size()) sum[x2+1]--;
// sum[x1]++;
// }
// for (int i=1;i<(int)sum.size();i++){
// sum[i] += sum[i-1];
// FUCK.push_back({sum[i], X[i], ry});
// }
// sum.clear();
// sum.resize(X.size());
// for (auto &[x1, y1, x2, y2]:nV) if (Y[y1] <= ly){
// if (x2+1 < (int)sum.size()) sum[x2+1]--;
// sum[x1]++;
// }
// for (int i=1;i<(int)sum.size();i++){
// sum[i] += sum[i-1];
// FUCK.push_back({sum[i], X[i], ly});
// }
sort(FUCK.begin(), FUCK.end(), greater<array<int, 3>>());
for (auto &[_, x, y]:FUCK) C.emplace_back(x, y);
// for (auto &[x1, y1, x2, y2]:V) if (x2 >= rx){
// int i1 = lower_bound(Y.begin(), Y.end(), y1) - Y.begin();
// int i2 = lower_bound(Y.begin(), Y.end(), y2) - Y.begin();
// if (i2+1 < (int)sum.size()) sum[i2+1]--;
// sum[i1]++;
// }
// for (int i=1;i<(int)sum.size();i++) sum[i] += sum[i-1], I[i] = i;
// sort(I.begin()+1, I.end(), [&](int i, int j){return sum[i] > sum[j];});
// for (int i0=1;i0<(int)I.size();i0++){
// int y = Y[I[i0]];
// C.emplace_back(rx, y);
// }
// for (auto &[x1, y1, x2, y2]:V) if (x2 >= rx){
// C.emplace_back(rx, y1);
// C.emplace_back(rx, y2);
// // C.emplace_back(x2, y1);
// // C.emplace_back(x2, y2);
// }
}
// int cnt = 0;
for (auto &[x, y]:C){
// ++cnt;
// assert(cnt < 100);
vector<Rect> nV;
for (auto &R:V) if (!R.in(x, y)) nV.push_back(R);
ans.emplace_back(x, y);
solve(nV, k-1);
ans.pop_back();
}
}
int main(){
int n, k;
scanf("%d %d", &n, &k);
vector<Rect> V(n);
for (int i=0;i<n;i++) V[i].read();
solve(V, k);
printf("failed\n");
return 0;
}
Compilation message
hamburg.cpp: In function 'int main()':
hamburg.cpp:151:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
151 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp: In member function 'void Rect::read()':
hamburg.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
584 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 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 |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
3 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 |
4 ms |
596 KB |
Output is correct |
14 |
Correct |
52 ms |
596 KB |
Output is correct |
15 |
Correct |
4 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
544 KB |
Output is correct |
17 |
Correct |
310 ms |
624 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
4 ms |
596 KB |
Output is correct |
20 |
Correct |
802 ms |
640 KB |
Output is correct |
21 |
Correct |
4 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
596 KB |
Output is correct |
23 |
Correct |
803 ms |
644 KB |
Output is correct |
24 |
Correct |
4 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
596 KB |
Output is correct |
26 |
Correct |
3 ms |
596 KB |
Output is correct |
27 |
Correct |
3 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
3 ms |
596 KB |
Output is correct |
31 |
Correct |
439 ms |
628 KB |
Output is correct |
32 |
Correct |
319 ms |
624 KB |
Output is correct |
33 |
Correct |
373 ms |
632 KB |
Output is correct |
34 |
Correct |
283 ms |
636 KB |
Output is correct |
35 |
Correct |
863 ms |
648 KB |
Output is correct |
36 |
Correct |
238 ms |
628 KB |
Output is correct |
37 |
Correct |
1121 ms |
684 KB |
Output is correct |
38 |
Correct |
858 ms |
680 KB |
Output is correct |
39 |
Correct |
140 ms |
640 KB |
Output is correct |
40 |
Correct |
640 ms |
628 KB |
Output is correct |
41 |
Correct |
192 ms |
624 KB |
Output is correct |
42 |
Correct |
191 ms |
672 KB |
Output is correct |
43 |
Correct |
558 ms |
636 KB |
Output is correct |
44 |
Correct |
84 ms |
596 KB |
Output is correct |
45 |
Correct |
4 ms |
596 KB |
Output is correct |
46 |
Correct |
668 ms |
660 KB |
Output is correct |
47 |
Correct |
998 ms |
688 KB |
Output is correct |
48 |
Correct |
392 ms |
648 KB |
Output is correct |
49 |
Correct |
929 ms |
672 KB |
Output is correct |
50 |
Correct |
348 ms |
648 KB |
Output is correct |
51 |
Correct |
947 ms |
716 KB |
Output is correct |
52 |
Correct |
431 ms |
628 KB |
Output is correct |
53 |
Correct |
392 ms |
676 KB |
Output is correct |
54 |
Correct |
308 ms |
652 KB |
Output is correct |
55 |
Correct |
539 ms |
608 KB |
Output is correct |
56 |
Correct |
540 ms |
616 KB |
Output is correct |
57 |
Correct |
593 ms |
596 KB |
Output is correct |
58 |
Correct |
593 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
72 ms |
6472 KB |
Output is correct |
6 |
Correct |
69 ms |
6528 KB |
Output is correct |
7 |
Correct |
65 ms |
6444 KB |
Output is correct |
8 |
Correct |
66 ms |
6528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
66 ms |
9020 KB |
Output is correct |
6 |
Correct |
71 ms |
8720 KB |
Output is correct |
7 |
Correct |
70 ms |
8920 KB |
Output is correct |
8 |
Correct |
87 ms |
17616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
584 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
68 ms |
9916 KB |
Output is correct |
14 |
Correct |
70 ms |
10156 KB |
Output is correct |
15 |
Correct |
82 ms |
8760 KB |
Output is correct |
16 |
Correct |
73 ms |
8960 KB |
Output is correct |
17 |
Correct |
69 ms |
11356 KB |
Output is correct |
18 |
Correct |
73 ms |
8856 KB |
Output is correct |
19 |
Correct |
73 ms |
11832 KB |
Output is correct |
20 |
Correct |
83 ms |
15360 KB |
Output is correct |
21 |
Correct |
179 ms |
27156 KB |
Output is correct |
22 |
Correct |
104 ms |
18596 KB |
Output is correct |
23 |
Correct |
95 ms |
21764 KB |
Output is correct |
24 |
Correct |
106 ms |
24552 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 |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
3 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 |
4 ms |
596 KB |
Output is correct |
14 |
Correct |
52 ms |
596 KB |
Output is correct |
15 |
Correct |
4 ms |
596 KB |
Output is correct |
16 |
Correct |
3 ms |
544 KB |
Output is correct |
17 |
Correct |
310 ms |
624 KB |
Output is correct |
18 |
Correct |
3 ms |
596 KB |
Output is correct |
19 |
Correct |
4 ms |
596 KB |
Output is correct |
20 |
Correct |
802 ms |
640 KB |
Output is correct |
21 |
Correct |
4 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
596 KB |
Output is correct |
23 |
Correct |
803 ms |
644 KB |
Output is correct |
24 |
Correct |
4 ms |
596 KB |
Output is correct |
25 |
Correct |
3 ms |
596 KB |
Output is correct |
26 |
Correct |
3 ms |
596 KB |
Output is correct |
27 |
Correct |
3 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
3 ms |
596 KB |
Output is correct |
31 |
Correct |
439 ms |
628 KB |
Output is correct |
32 |
Correct |
319 ms |
624 KB |
Output is correct |
33 |
Correct |
373 ms |
632 KB |
Output is correct |
34 |
Correct |
283 ms |
636 KB |
Output is correct |
35 |
Correct |
863 ms |
648 KB |
Output is correct |
36 |
Correct |
238 ms |
628 KB |
Output is correct |
37 |
Correct |
1121 ms |
684 KB |
Output is correct |
38 |
Correct |
858 ms |
680 KB |
Output is correct |
39 |
Correct |
140 ms |
640 KB |
Output is correct |
40 |
Correct |
640 ms |
628 KB |
Output is correct |
41 |
Correct |
192 ms |
624 KB |
Output is correct |
42 |
Correct |
191 ms |
672 KB |
Output is correct |
43 |
Correct |
558 ms |
636 KB |
Output is correct |
44 |
Correct |
84 ms |
596 KB |
Output is correct |
45 |
Correct |
4 ms |
596 KB |
Output is correct |
46 |
Correct |
668 ms |
660 KB |
Output is correct |
47 |
Correct |
998 ms |
688 KB |
Output is correct |
48 |
Correct |
392 ms |
648 KB |
Output is correct |
49 |
Correct |
929 ms |
672 KB |
Output is correct |
50 |
Correct |
348 ms |
648 KB |
Output is correct |
51 |
Correct |
947 ms |
716 KB |
Output is correct |
52 |
Correct |
431 ms |
628 KB |
Output is correct |
53 |
Correct |
392 ms |
676 KB |
Output is correct |
54 |
Correct |
308 ms |
652 KB |
Output is correct |
55 |
Correct |
539 ms |
608 KB |
Output is correct |
56 |
Correct |
540 ms |
616 KB |
Output is correct |
57 |
Correct |
593 ms |
596 KB |
Output is correct |
58 |
Correct |
593 ms |
604 KB |
Output is correct |
59 |
Correct |
257 ms |
26280 KB |
Output is correct |
60 |
Correct |
269 ms |
26276 KB |
Output is correct |
61 |
Correct |
258 ms |
26240 KB |
Output is correct |
62 |
Correct |
260 ms |
26280 KB |
Output is correct |
63 |
Correct |
266 ms |
26272 KB |
Output is correct |
64 |
Correct |
268 ms |
26276 KB |
Output is correct |
65 |
Correct |
267 ms |
26308 KB |
Output is correct |
66 |
Correct |
264 ms |
26384 KB |
Output is correct |
67 |
Correct |
313 ms |
29928 KB |
Output is correct |
68 |
Correct |
285 ms |
26340 KB |
Output is correct |
69 |
Correct |
289 ms |
26104 KB |
Output is correct |
70 |
Correct |
281 ms |
27504 KB |
Output is correct |
71 |
Correct |
680 ms |
40344 KB |
Output is correct |
72 |
Execution timed out |
3083 ms |
37888 KB |
Time limit exceeded |
73 |
Halted |
0 ms |
0 KB |
- |