[BJ15973] 두 박스 .

2019. 7. 24. 01:06ComputerScience/Algorithm

https://www.acmicpc.net/problem/15973

 

15973번: 두 박스

표준 입력으로 두 박스의 정보가 한 줄에 하나씩 주어진다. 각 박스의 정보는 왼쪽 아래 꼭짓점 좌표 (x1, y1)과 오른쪽 위 꼭짓점 좌표 (x2, y2)로 구성되는데 이들 좌푯값 x1, y1, x2, y2 (x1 < x2, y1 < y2)가 공백을 사이에 두고 주어진다.

www.acmicpc.net

맞긴맞았으나 내 풀이가 너무길고 맘에 안든다 숏코딩한사람들의 10배정도 되는거같은데

이렇게 안풀기를 다짐하면서 코드를 박제함

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define pii pair<int,int> 
int main() {
	int box1[2][2];
	int box2[2][2];
	//( x1 y1 )
	//( x2 y2 )
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++)
			cin >> box1[i][j];
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++)
			cin >> box2[i][j];
	if (box1[1][0] < box2[0][0] || box1[0][0]>box2[1][0]) {
		cout << "NULL";
	}
	else {
		if (box1[1][1] < box2[0][1] || box1[0][1]>box2[1][1]) {
			cout << "NULL";
		}
		else {
			if (box1[0][0] == box2[0][0]) {
				if (box1[0][1] == box2[1][1] || box1[1][1] == box2[0][1])
					cout << "LINE";
				else
					cout << "FACE";
			}
			else if (box1[0][0] == box2[1][0]) {
				if (box1[0][1] == box2[1][1] || box1[1][1] == box2[0][1])
					cout << "POINT";
				else
					cout << "LINE";
			}
			else if (box1[1][0] == box2[1][0]) {
				if (box1[0][1] == box2[1][1] || box1[1][1] == box2[0][1])
					cout << "LINE";
				else
					cout << "FACE";
			}
			else if (box1[1][0] == box2[0][0]) {
				if (box1[0][1] == box2[1][1] || box1[1][1] == box2[0][1])
					cout << "POINT";
				else
					cout << "LINE";
			}
			else {
				if (box1[0][1] == box2[1][1] || box1[1][1] == box2[0][1])
					cout << "LINE";
				else
					cout << "FACE";
			}
		}
	}
}

'ComputerScience > Algorithm' 카테고리의 다른 글

[BOJ2580] 스도쿠  (0) 2020.10.28
[BJ15975] 화살표 그리기  (0) 2019.07.25
[BJ 15971] 두 로봇  (0) 2019.07.24