QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#15064. Glico

統計

JYY really likes eating Pocky. One day, he and his friends bought $N$ Pocky sticks to share. He scattered these Pocky sticks on a table, where each Pocky stick can be viewed as a line segment on a 2D plane (due to different varieties, their lengths are not necessarily the same).

Now, JYY has an infinitely long knife (which can be viewed as a straight line). He wants to find a position to make a cut such that every Pocky stick is cut into two pieces (they can be of different lengths; even if the knife passes through any point on the Pocky stick, including the endpoints, it is considered to have cut it into two pieces). This way, they can be shared among his friends.

Please calculate whether there exists a method to cut all of them into two pieces with a single cut.

Input

The first line contains a positive integer $N$, representing the number of Pocky sticks.

The next $N$ lines each contain 4 floating-point numbers: $x_1, y_1, x_2, y_2$, representing a Pocky stick located at coordinates $(x_1, y_1)$ to $(x_2, y_2)$.

Output

The first line should output a capital letter 'T' or 'F'. 'T' indicates that a method satisfying the requirements exists, otherwise 'F' indicates it does not.

If 'T' is output, the second line should output 4 real numbers $x_1, y_1, x_2, y_2$, representing the line that the knife passes through.

Note: We require the output solution to satisfy $(x_1 - x_2)^2 + (y_1 - y_2)^2 \geq 1$.

Subtasks

This problem uses a special judge, and the solution in the output file can be real numbers with arbitrary precision. The precision error used in the checker is $eps=1e-5$. For each test case, if the standard answer is F, answering T results in 0 points, and answering F results in 10 points; if the standard answer is T, answering F results in 0 points, and answering T results in 1 point, with an additional 9 points if the position is also correct (total 10 points).

Examples

Input 1

2
0.0 0.0 1.0 0.0
1.0 1.0 2.0 1.0

Output 1

T
0.5 0.0 1.5 1.0

Input 2

3
0.0 0.0 1.0 0.0
1.1 1.1 2.1 1.1
0.0 2.0 1.0 2.0

Output 2

F

Constraints

For 10% of the data, $N = 3$; For 20% of the data, $N \leq 10$; For 50% of the data, $N \leq 200$; For 100% of the data, $3 \leq N \leq 1000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.