Logo
(追記) (追記ここまで)

7657번 - Rectangles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB62221431.111%

문제

A rectangle in the Cartesian plane is specified by a pair of coordinates (\(x_1\), \(y_1\)) and (\(x_2\), \(y_2\)) indicating its lower-left and upper-right corners, respectively (where \(x_1\) ≤ \(x_2\) and \(y_1\) ≤ \(y_2\)). Given a pair of rectangles, \(A\) = ((\(x_1^A\), \(y_1^A\)), (\(x_2^A\), \(y_2^A\))) and \(B\) = ((\(x_1^B\), \(y_1^B\)), (\(x_2^B\), \(y_2^B\))), we write \(A\) ⪯ \(B\) (i.e., \(A\) "precedes" \(B\)), if

\(x_2^A\) < \(x_1^B\) and \(y_2^A\) < \(y_1^B\).

In this problem, you are given a collection of rectangles located in the two-dimension Euclidean plane. Find the length L of the longest sequence of rectangles (\(A_1\), \(A_2\), ..., \(A_L\)) from this collection such that

\(A_1\) ⪯ \(A_2\) ⪯ ... ⪯ \(A_L\).

입력

The input file will contain multiple test cases. Each test case will begin with a line containing a single integer \(n\) (where 1 ≤ \(n\) ≤ 1000), indicating the number of input rectangles. The next \(n\) lines each contain four integers \(x_1^i\) \(y_1^i\) \(x_2^i\) \(y_2^i\) (where −1000000 ≤ \(x_1^i\) ≤ \(x_2^i\) ≤ 1000000, −1000000 ≤ \(y_1^i\) ≤ \(y_2^i\) ≤ 1000000, and 1 ≤ \(i\) ≤ \(n\)), indicating the lower left and upper right corners of a rectangle. The end-of-file is denoted by a single line containing the integer 0.

출력

For each input test case, print a single integer indicating the length of the longest chain.

제한

예제 입력 1

3
1 5 2 8
3 -1 5 4
10 10 20 20
2
2 1 4 5
6 5 8 10
0

예제 출력 1

2
1

힌트

출처

University > Stanford Local ACM Programming Contest > SLPC 2009 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /