Codeforces #1063C dwarves, Hats and extrasensory abilities

Source: Internet
Author: User

Main topic

Interactive questions.
The coordinates of a point on the output plane, which the interaction program gives to this point (white or black).
So repeat $n $ ($ 1\le n \le 30$).
The $n $ points required for the output are different, and no matter how they are dyed by the interactive program, they can find a straight line separating the white and black dots (the dividing line cannot pass through the staining point).
The coordinates of two points on the output divider line.

Requirement: All coordinates of the output must be an integer between $0$ and $10^9$.

Solution

It is not difficult to think of $n $ points can be selected in a line parallel to the $x $ axis.

Each time you take the midpoint of the line of the middle two adjacent black and white dots.

Since the ordinate is a constant, we only consider the horizontal axis below.

The first point of the (horizontal) coordinates selected as $0$, it is advisable to set the first point is given white, at this time we assume that the $10^9+1$ is a (virtual) black spot.
Each time you select the two dots of the adjacent black-and-white point $ L + (R-L)/2$ or $ (l+r)/2$ (note: This notation has the risk of overflow).

My train of thought was roughly right, but at the end of the output divider, I chose a straight line perpendicular to the $x $ axis, making it with $x $ (l + 1, 0) $, $l $ is the horizontal axis of the rightmost white point.

But I didn't think of a situation where the distance between the two black and white dots adjacent to the middle is probably $1$ (this is due to $2^{30} > 10^9+1$. In fact, if the $x = 10^9 + 1$, will be $x \gets \lceil x/2 \rceil$ repeatedly execute $29$ times, there must be $x = 1$; will $x \gets \lfloor x/2 \rfloor$ repeated $29$ times also necessarily There is $x = 1$), at which point the dividing line passes through the leftmost black dot. It is easy to see that if the divider is perpendicular to the $x $ axis, it occupies a position on the horizontal line where the black and white dots are located ($10^9 + 1$ positions in total). We can choose a diagonal line as the divider line, because eventually there must be $l < R $, we can make the black and white point of the ordinate is $1$, so the separation line is advisable to pass $ (l, 0) $ and $ (r, 2) $ two points straight line.

Codeforces #1063C dwarves, Hats and extrasensory abilities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.