답안 #212585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
212585 2020-03-23T16:10:25 Z ainta 함박 스테이크 (JOI20_hamburg) C++17
6 / 100
152 ms 3452 KB
#include<cstdio>
#include<algorithm>
#define N_ 201000
using namespace std;
int n, K;
struct Rect {
	int bx, by, ex, ey;
}w[N_];
struct point{
	int x,y;
};
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 Go(int ax, int ay, int bx, int by) {
	int i;
	point A = { ax,ay }, B = { bx,by };

	int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9;
	for (i = 1; i <= n; i++) {
		if (!Inside(w[i], A) && !Inside(w[i], B)) {
			if (K == 2)return;
			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 (K == 2) {
		Print(A);
		Print(B);
		exit(0);
	}
	if (K == 3 && Ax <= Bx && Ay <= By) {
		point C = { Ax,Ay };
		Print(A); Print(B); Print(C);
		exit(0);
	}

}
int main() {
	int i;
	scanf("%d%d", &n, &K);
	int Ax = 0, Bx = 1e9, Ay = 0, By = 1e9;
	for (i = 1; i <= n; i++) {
		scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey);
		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 (K == 1) {
		printf("%d %d\n", Ax, Ay);
		return 0;
	}
	if (K <= 3) {
		Go(Ax, Ay, Bx, By);
		Go(Ax, By, Bx, Ay);
		return 0;
	}

}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |  scanf("%d%d", &n, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |   scanf("%d%d%d%d", &w[i].bx, &w[i].by, &w[i].ex, &w[i].ey);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 320 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
# 결과 실행 시간 메모리 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 2 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 2 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
5 Correct 145 ms 3448 KB Output is correct
6 Correct 133 ms 3448 KB Output is correct
7 Correct 131 ms 3448 KB Output is correct
8 Correct 134 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 320 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 146 ms 3452 KB Output is correct
6 Correct 130 ms 3448 KB Output is correct
7 Correct 152 ms 3452 KB Output is correct
8 Correct 129 ms 3448 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 2 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 2 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -