405839: GYM102133 J Find a triangle

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Find a triangletime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Someone has drawn a non-degenerate triangle with integer coordinates of vertexes on a chequered piece of paper. However, he did not tell anyone, where this triangle is located. Therefore, you are very curious about it. Fortunately, this guy agreed to answer your questions about it. You have to tell him coordinates of two different points (x1, y1) and (x2, y2) and he will draw a directed line and will tell you whether it crosses a triangle or not. If a line crosses the triangle this guy will tell you if the triangle is located on the left or on the right relative to the line.

The answer to each of the questions can be described as follows.

  • '+' the triangle is fully located on the right relative to the line.
  • '-' the triangle is fully located on the left relative to the line.
  • 'X' line crosses the triangle at least in one point
Someone will be very bored if you ask him more than 600 questions and will refuse to answer afterwards.Input

After each request you will be given a line, which can be one of three possible characters ('-', '+' or 'X').

Output

To make a request you have to print a line according to a following format. All coordinates must be integer. Q x1 y1 x2 y2.

|x1|, |x2|, |y1|, |y2| ≤ 42 × 104

If you figured out the final location of the triangle, you have to print the line in a following format A x1 y1 x2 y2 x3 y3. If you guessed the correct location of the triangle, the order of points does not affect the correctness of your answer.

|x1|, |x2|, |x3|, |y1|, |y2|, |y3| ≤ 105

Please note, that you have to print a new line character after each request and flush the buffer. For example, you can do it using fflush(stdout) in C++, System.out.flush() in Java, and flush(output) in Pascal.

加入题单

算法标签: