1591. Intersection

单点时限: 2.0 sec

内存限制: 256 MB

You are to write a program that has to decide whether a given line segment intersects a given rectangle.

An example:

  • line: start point: $(4,9)$
  • end point: $(11,2)$
  • rectangle: left-top: $(1,5)$
  • right-bottom: $(7,1)$

Figure 1: Line segment does not intersect rectangle

The line is said to intersect the rectangle if the line and the rectangle have at least one point in common. The rectangle consists of four straight lines and the area in between. Although all input values are integer numbers, valid intersection points do not have to lay on the integer grid.

输入格式

The input consists of $n$ test cases. The first line of the input file contains the number $n$. Each following line contains one test case of the format:

$xstart \ ystart \ xend \ yend \ xleft \ ytop \ xright \ ybottom$

where $(xstart, ystart)$ is the start and $(xend, yend)$ the end point of the line and $(xleft, ytop)$ the top left and $(xright, ybottom)$ the bottom right corner of the rectangle. The eight numbers are separated by a blank. The terms top left and bottom right do not imply any ordering of coordinates.

All integers in the input have absolute values less than $100$.

输出格式

For each test case in the input file, the output file should contain a line consisting either of the letter T if the line segment intersects the rectangle or the letter F if the line segment does not intersect the rectangle.

样例

Input
1
4 9 11 2 1 5 7 1
Output
F

16 人解决,22 人已尝试。

21 份提交通过,共有 91 份提交。

5.4 EMB 奖励。

创建: 13 年前.

修改: 2 年,9 月前.

最后提交: 1 年,10 月前.

来源: UVa

题目标签