답안 #787383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787383 2023-07-19T06:39:20 Z 박상훈(#10032) 함박 스테이크 (JOI20_hamburg) C++17
21 / 100
3000 ms 43044 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){
		for (auto &[x1, y1, x2, y2]:V){
			C.emplace_back(rx, y1);
			C.emplace_back(rx, y2);
			// C.emplace_back(x2, y1);
			// C.emplace_back(x2, y2);
		}
	}
	for (auto &[x, y]:C){
		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:60:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  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 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 1 ms 308 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 2 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 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 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 2 ms 444 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 402 ms 656 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 115 ms 728 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 4 ms 696 KB Output is correct
20 Correct 180 ms 736 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 3 ms 720 KB Output is correct
23 Correct 168 ms 748 KB Output is correct
24 Correct 3 ms 664 KB Output is correct
25 Correct 2 ms 664 KB Output is correct
26 Correct 2 ms 724 KB Output is correct
27 Correct 2 ms 672 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 388 ms 1060 KB Output is correct
32 Correct 36 ms 720 KB Output is correct
33 Correct 614 ms 756 KB Output is correct
34 Correct 102 ms 732 KB Output is correct
35 Correct 134 ms 736 KB Output is correct
36 Correct 614 ms 724 KB Output is correct
37 Correct 35 ms 760 KB Output is correct
38 Correct 591 ms 736 KB Output is correct
39 Correct 50 ms 700 KB Output is correct
40 Correct 135 ms 788 KB Output is correct
41 Correct 340 ms 732 KB Output is correct
42 Correct 169 ms 712 KB Output is correct
43 Correct 45 ms 728 KB Output is correct
44 Correct 242 ms 732 KB Output is correct
45 Correct 2 ms 620 KB Output is correct
46 Correct 251 ms 744 KB Output is correct
47 Correct 90 ms 728 KB Output is correct
48 Correct 167 ms 724 KB Output is correct
49 Correct 116 ms 744 KB Output is correct
50 Correct 74 ms 756 KB Output is correct
51 Correct 902 ms 800 KB Output is correct
52 Correct 88 ms 708 KB Output is correct
53 Correct 9 ms 720 KB Output is correct
54 Correct 524 ms 736 KB Output is correct
55 Correct 9 ms 680 KB Output is correct
56 Correct 16 ms 656 KB Output is correct
57 Correct 11 ms 668 KB Output is correct
58 Correct 4 ms 596 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 76 ms 6548 KB Output is correct
6 Correct 71 ms 6448 KB Output is correct
7 Correct 75 ms 6552 KB Output is correct
8 Correct 72 ms 6464 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 9064 KB Output is correct
6 Correct 74 ms 8764 KB Output is correct
7 Correct 72 ms 8960 KB Output is correct
8 Correct 85 ms 17560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 308 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 2 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 83 ms 9976 KB Output is correct
14 Correct 78 ms 10192 KB Output is correct
15 Correct 72 ms 8784 KB Output is correct
16 Correct 73 ms 8856 KB Output is correct
17 Correct 75 ms 11312 KB Output is correct
18 Correct 73 ms 8768 KB Output is correct
19 Correct 76 ms 11880 KB Output is correct
20 Correct 82 ms 15336 KB Output is correct
21 Correct 182 ms 27020 KB Output is correct
22 Correct 105 ms 18608 KB Output is correct
23 Correct 98 ms 21852 KB Output is correct
24 Correct 110 ms 24568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 2 ms 444 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 402 ms 656 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 115 ms 728 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 4 ms 696 KB Output is correct
20 Correct 180 ms 736 KB Output is correct
21 Correct 4 ms 724 KB Output is correct
22 Correct 3 ms 720 KB Output is correct
23 Correct 168 ms 748 KB Output is correct
24 Correct 3 ms 664 KB Output is correct
25 Correct 2 ms 664 KB Output is correct
26 Correct 2 ms 724 KB Output is correct
27 Correct 2 ms 672 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 388 ms 1060 KB Output is correct
32 Correct 36 ms 720 KB Output is correct
33 Correct 614 ms 756 KB Output is correct
34 Correct 102 ms 732 KB Output is correct
35 Correct 134 ms 736 KB Output is correct
36 Correct 614 ms 724 KB Output is correct
37 Correct 35 ms 760 KB Output is correct
38 Correct 591 ms 736 KB Output is correct
39 Correct 50 ms 700 KB Output is correct
40 Correct 135 ms 788 KB Output is correct
41 Correct 340 ms 732 KB Output is correct
42 Correct 169 ms 712 KB Output is correct
43 Correct 45 ms 728 KB Output is correct
44 Correct 242 ms 732 KB Output is correct
45 Correct 2 ms 620 KB Output is correct
46 Correct 251 ms 744 KB Output is correct
47 Correct 90 ms 728 KB Output is correct
48 Correct 167 ms 724 KB Output is correct
49 Correct 116 ms 744 KB Output is correct
50 Correct 74 ms 756 KB Output is correct
51 Correct 902 ms 800 KB Output is correct
52 Correct 88 ms 708 KB Output is correct
53 Correct 9 ms 720 KB Output is correct
54 Correct 524 ms 736 KB Output is correct
55 Correct 9 ms 680 KB Output is correct
56 Correct 16 ms 656 KB Output is correct
57 Correct 11 ms 668 KB Output is correct
58 Correct 4 ms 596 KB Output is correct
59 Correct 81 ms 24952 KB Output is correct
60 Correct 80 ms 22868 KB Output is correct
61 Correct 79 ms 23432 KB Output is correct
62 Correct 80 ms 21924 KB Output is correct
63 Correct 79 ms 23520 KB Output is correct
64 Correct 77 ms 20320 KB Output is correct
65 Correct 92 ms 23808 KB Output is correct
66 Correct 79 ms 23164 KB Output is correct
67 Correct 150 ms 37396 KB Output is correct
68 Correct 99 ms 31920 KB Output is correct
69 Correct 88 ms 27264 KB Output is correct
70 Correct 98 ms 33212 KB Output is correct
71 Correct 480 ms 42936 KB Output is correct
72 Execution timed out 3075 ms 43044 KB Time limit exceeded
73 Halted 0 ms 0 KB -