Fractal Painting

시간 제한1초메모리 제한2048 MB

요약
세 선분이 이루는 기본 도형을 재귀적으로 닮은꼴로 이어 붙여 만든 프랙탈이 어떤 직사각형 안에 들어가는지 판정한다.
난이도

보통10점 중 7점

유형
기하, 재귀, 수학, 분할 정복
정답자
아직 제출이 없습니다

문제

A fractal painting consists of an infinite number of line segments. The first segment, called A, connects points (0,0)(0, 0) and (x_0,y_0)(x\_0, y\_0).

The next two segments B and C connect (x_0,y_0)(x\_0, y\_0) to (x_1,y_1)(x\_1, y\_1) and (x_0,y_0)(x\_0, y\_0) to (x_2,y_2)(x\_2, y\_2), respectively.

The rest of the painting is defined recursively. We draw two segments D and E from (x_1,y_1)(x\_1, y\_1) so that the segments B, D, E are similar to the segments A, B, C. Here, similar segments mean that they can be matched point-to-point by performing translating, rotating, and scaling on the original segments.

Similarly, we draw segments F and G from (x_2,y_2)(x\_2, y\_2) so that the segments C, F, G are similar to the segments A, B, C.

This procedure continues indefinitely.

Find out whether it is possible to find a rectangle (of any size) that contains the entire fractal painting.

입력

The first line of input contains a single integer TT (1≤T≤104)(1 \le T \le 10^4), representing the number of test cases. Each of the next TT lines describes a single test case. Each test case consists of a single line with six integers x_0x\_0, y_0y\_0, x_1x\_1, y_1y\_1, x_2x\_2, and y_2y\_2 in order. All coordinates are between −104-10^4 and 10410^4, inclusive. It is guaranteed that (0,0)(0, 0), (x_0,y_0)(x\_0, y\_0), (x_1,y_1)(x\_1, y\_1), and (x_2,y_2)(x\_2, y\_2) are all distinct points.

출력

For every test case, output YES if the entire fractal painting can fit in some rectangular frame. Output NO if there is no such rectangle.

예제1

  1. 예제 1

    입력
    3
    1 3 -1 3 3 4
    1 1 67 0 0 67
    67 67 1 0 0 1
    
    예상 출력
    YES
    NO
    YES