Submission #216737

# Submission time Handle Problem Language Result Execution time Memory
216737 2020-03-28T00:08:23 Z ainta Hamburg Steak (JOI20_hamburg) C++17
15 / 100
402 ms 4368 KB
#include<cstdio>
#include<algorithm>
#define N_ 201000
using namespace std;
int n, K, C[N_];
struct Rect {
	int bx, by, ex, ey;
}w[N_];
struct point {
	int x, y;
}U[5];
bool Inside(Rect a, point b) {
	return a.bx <= b.x&&b.x <= a.ex&&a.by <= b.y&&b.y <= a.ey;
}
void Print(point a) {
	printf("%d %d\n", a.x, a.y);
}
void Do(int pv) {
	int i;
	if (pv) {
		for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]++;
	}
	if (pv == K) {
		for (i = 1; i <= n; i++) if (!C[i])break;
		if (i > n) {
			for (i = 0; i < K; i++)Print(U[i]);
			exit(0);
		}
		for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--;
		return;
	}
	int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9;
	for (i = 1; i <= n; i++) {
		if (C[i])continue;
		Ax = max(Ax, w[i].bx);
		Ay = max(Ay, w[i].by);
		Bx = min(Bx, w[i].ex);
		By = min(By, w[i].ey);
	}
	int yy1 = 0, yy2 = 1e9, yy3 = 0, yy4 = 1e9;
	for (i = 1; i <= n; i++) {
		if (C[i])continue;
		if (w[i].bx <= Bx) {
			yy1 = max(yy1, w[i].by);
			yy2 = min(yy2, w[i].ey);
		}
		if (w[i].ex >= Ax) {
			yy3 = max(yy3, w[i].by);
			yy4 = min(yy4, w[i].ey);
		}
	}
	U[pv] = { Bx, yy1 };
	Do(pv + 1);
	U[pv] = { Bx, yy2 };
	Do(pv + 1);
	U[pv] = { Ax, yy3 };
	Do(pv + 1);
	U[pv] = { Ax, yy4 };
	Do(pv + 1);
	if (pv) {
		for (i = 1; i <= n; i++)if (Inside(w[i], U[pv - 1]))C[i]--;
	}
}
int main() {
	int i;
	scanf("%d%d", &n, &K);
	for (i = 1; i <= n; i++) {
		scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey);
	}
	Do(0);
	int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9;
	for (i = 1; i <= n; i++) {
		Ax = max(Ax, w[i].bx);
		Ay = max(Ay, w[i].by);
		Bx = min(Bx, w[i].ex);
		By = min(By, w[i].ey);
	}
	if (Ax <= Bx || Ay <= By) {
		while (1) {}
	}
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   66 |  scanf("%d%d", &n, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |   scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 288 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory 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 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 8 ms 384 KB Output is correct
14 Incorrect 13 ms 384 KB Unexpected end of file - int32 expected
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 148 ms 4216 KB Output is correct
6 Correct 143 ms 4240 KB Output is correct
7 Correct 146 ms 4216 KB Output is correct
8 Correct 155 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 2 ms 384 KB Output is correct
5 Correct 173 ms 4188 KB Output is correct
6 Correct 157 ms 4368 KB Output is correct
7 Correct 225 ms 4260 KB Output is correct
8 Correct 175 ms 4256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 288 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 179 ms 4216 KB Output is correct
14 Correct 170 ms 4216 KB Output is correct
15 Correct 152 ms 4176 KB Output is correct
16 Correct 157 ms 4216 KB Output is correct
17 Correct 153 ms 4216 KB Output is correct
18 Correct 159 ms 4152 KB Output is correct
19 Correct 259 ms 4260 KB Output is correct
20 Correct 240 ms 4216 KB Output is correct
21 Correct 284 ms 4188 KB Output is correct
22 Correct 402 ms 4216 KB Output is correct
23 Correct 170 ms 4216 KB Output is correct
24 Correct 148 ms 4216 KB Output is correct
# Verdict Execution time Memory 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 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 8 ms 384 KB Output is correct
14 Incorrect 13 ms 384 KB Unexpected end of file - int32 expected
15 Halted 0 ms 0 KB -