시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB270513922.286%

문제

The future is here! The Boxes And Parcels Centre has decided to start delivering parcels using drones. Being a BrAinPort Company, naturally the first deliveries will be to Eindhoven.

To keep the flight logic simple, the first prototype will only deliver to the roofs of the tallest buildings. After take-off, the drone will take a $w\times h$ ($1 \leq w\leq 10\,000$, $1\leq h\leq 10^{18}$) photo of the skyline, as shown in Figure J.1. You have been tasked with the problem of determining the location and height of the tallest building in this photo, so that the drone knows where to go.

You have access to a classifier that can determine for each pixel whether it is "sky" or "building". You can use this multiple times for different pixels. To avoid unnecessary delays, you may run the classifier at most $12\,000$ times.

It is guaranteed that the buildings will not contain any hovering parts: whenever a pixel that is not on the bottom row of the photo is classified as building, the pixels below it will also be classified as building.

Figure J.1: The skyline of the sample interaction.

인터랙션

This is an interactive problem. Your submission will be run against an interactor, which reads from the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:

The interactor first sends one line with two integers $w$ and $h$ ($1\leq w\leq 10\,000$, $1\leq h\leq 10^{18}$), the width and height of the photo in pixels.

Then, your program should make at most $12\,000$ queries to find the highest building. Each query is made by printing one line of the form "? $x$ $y$" ($1\leq x\leq w$, $1\leq y\leq h$). The interactor will respond with either "sky" or "building", indicating the classification of the pixel at coordinates $(x, y)$.

When you have determined the $x$-coordinate of one of the highest buildings and its height $y$, print one line of the form "! $x$ $y$", after which the interaction will stop. Printing the answer does not count as a query.

The interactor is not adaptive: the skyline is fixed up front, and does not depend on your queries.

If there are multiple valid solutions, you may output any one of them.

Make sure you flush the buffer after each write.

A testing tool is provided to help you develop your solution.

Using more than $12\,000$ queries will result in a wrong answer.

예제 입력 1

10 6

sky

building

sky

building

예제 출력 1


? 1 1

? 3 5

? 7 3

? 9 2

! 3 5

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2022 J번

  • 문제를 만든 사람: Reinier Schmiermann

채점 및 기타 정보

  • 예제는 채점하지 않는다.