Submission #787376

# Submission time Handle Problem Language Result Execution time Memory
787376 2023-07-19T06:34:28 Z 박상훈(#10032) Hamburg Steak (JOI20_hamburg) C++17
15 / 100
177 ms 34812 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}};
	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:52:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |  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);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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
# Verdict Execution time Memory 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 2 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 560 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 1 ms 572 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 388 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 508 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Incorrect 3 ms 660 KB Expected integer, but "failed" found
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 78 ms 6824 KB Output is correct
6 Correct 72 ms 6812 KB Output is correct
7 Correct 71 ms 6808 KB Output is correct
8 Correct 77 ms 6964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 75 ms 9160 KB Output is correct
6 Correct 102 ms 8860 KB Output is correct
7 Correct 76 ms 9164 KB Output is correct
8 Correct 89 ms 17736 KB Output is correct
# Verdict Execution time Memory 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 2 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 560 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 1 ms 572 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
13 Correct 76 ms 17724 KB Output is correct
14 Correct 86 ms 17956 KB Output is correct
15 Correct 76 ms 16616 KB Output is correct
16 Correct 75 ms 16632 KB Output is correct
17 Correct 89 ms 19036 KB Output is correct
18 Correct 83 ms 16576 KB Output is correct
19 Correct 77 ms 19516 KB Output is correct
20 Correct 81 ms 23020 KB Output is correct
21 Correct 177 ms 34812 KB Output is correct
22 Correct 108 ms 26384 KB Output is correct
23 Correct 98 ms 29536 KB Output is correct
24 Correct 124 ms 32272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 380 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 388 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 508 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Incorrect 3 ms 660 KB Expected integer, but "failed" found
15 Halted 0 ms 0 KB -