#P11193. [COTS 2021] 虫 Kukac
[COTS 2021] 虫 Kukac
Background
Translated from Izborne Pripreme 2021 (Croatian IOI/CEOI Team Selection) D1T2. 。
As everyone knows, insects can only sense clockwise and counterclockwise directions.
If you suspect the SPJ is incorrect, please contact the problem porter. SPJ code。
Problem Description
This is an interactive problem.
On a 2D plane, there is a polygon with points. Note that is not necessarily convex (it can be concave). We number the points on the polygon in order from to .
In addition, there is an extra point . Determine through interaction whether it is inside .
It is guaranteed that the polygon edges do not intersect. It is guaranteed that these points are pairwise distinct. It is guaranteed that no three points are collinear.
Definition: are in counterclockwise order if and only if, when looking from to , point is on the left side of the line , as shown in the left figure.

【Implementation Details】
Before the interaction starts, you need to read a line with two integers , representing the number of vertices of the polygon and the maximum number of queries allowed.
Then, your program interacts with the interactive library through standard input/output. The following queries are allowed:
-
: Ask whether points are in counterclockwise order. You must ensure that are pairwise distinct, and that .
If are in counterclockwise order, the answer is ; otherwise, the answer is .
After you determine the answer, output it in the following format:
- : If , it means point is inside the polygon; if , it means point is not inside the polygon.
After each output, do not forget to flush the buffer, for example: std::cout.flush()。
Input Format
See 【Implementation Details】.
Output Format
See 【Implementation Details】.
5 125
1
1
0
0
? 1 2 3
? 0 4 1
? 2 5 4
? 0 1 5
! 0
Hint
Sample Explanation

Constraints
For of the testdata, it is guaranteed that .
Reminder again: the polygon is not necessarily convex. It is guaranteed that the polygon edges do not intersect. It is guaranteed that these points are pairwise distinct. It is guaranteed that no three points are collinear.
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| Yes | ||||
| No | ||||
Special Property: is convex.
Translated by ChatGPT 5