※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 7782번 문제인 Alien이다.
문제는 아래 링크를 확인하자.

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

 

7782번: Alien

Once upon a time after winning another competition at KBTU, Bakhytzhan, Askar and Artem walked throw the Old Square. When they found some interesting rectangle lines on the asphalt, they stopped and screamed out ”R tree”. They screamed so loud that all

www.acmicpc.net

주어지는 N개의 직사각형 영역 중 좌표 (b1,b2)를 포함하는 직사각형이 존재하는지를 판단하는 문제이다.

 

이는 반복문과 조건문을 적절히 이용해 알아낼 수 있다.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;
typedef long long ll;

int N;
int x, y;
int X1, Y1, X2, Y2;
bool chk = 0;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> x >> y;
	while (N--) {
		cin >> X1 >> Y1 >> X2 >> Y2;
		if (X1 <= x && x <= X2 && Y1 <= y && y <= Y2) chk = 1;
	}

	if (chk) cout << "Yes";
	else cout << "No";
}
728x90

+ Recent posts