Triangles
Time limit2sMemory limit1024 MB
Given a green triangle and n marked points, find three of the points that form a blue triangle strictly containing the green one, or report NO.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Binary search
- Solved
- No attempts yet
Problem
Peter is a freshman at the university. His biggest problem is analytical geometry, because his mind simply resists anything new.
Peter is bored at analytical geometry lectures, but he attends them anyway. Right now he is sitting in one of these lectures and looking for something to entertain himself. Peter loves triangles. They are simple, and he knows them well. He has a sheet of paper and a blue ballpen. He put dots on the sheet and decided to connect them with lines and fill the triangles in blue.
At that moment the bell rings, and everyone leaves the room for a break. When Peter returns, he finds that someone has drawn a green triangle on his paper. He does not like green. He wants to draw his own blue triangle with three of the marked dots as vertices, so that it covers the green triangle. The green triangle must lie strictly inside the blue one, so the boundaries of the two triangles must have no common points. Peter has not been listening to his professor and cannot solve the problem alone, so he asks you for help.
Input
The first three lines of the input contain two integers each, the coordinates of the vertices of the green triangle, given in counterclockwise order. The triangle is guaranteed not to be degenerate.
The fourth line contains an integer , the number of marked dots (). Each of the next lines contains two integers, the coordinates of one dot. All dots are guaranteed to be pairwise distinct.
All coordinates have absolute value at most .
Output
If the desired blue triangle that strictly contains the green triangle does not exist, print NO.
Otherwise, print YES on the first line. On the second line, print the numbers of the dots that are the vertices of the blue triangle, in counterclockwise order. Dots are numbered from 1 in the order they appear in the input. If there are several solutions, print any of them.