#P7004. NEERC Rocket Interception
NEERC Rocket Interception
NEERC Rocket Interception
This is an interactive problem.
The North Eastern Emergency Rocket Control agency (NEERC) has developed a new radar control system that is designed to better control ballistic rocket interception. In order to test the new system, NEERC developed a mathematical model that demonstrates its abilities.
We represent a rocket as a point on a line. Initially the point is at some unknown integer location between \(0\) and \(p\) (inclusive), and it has some unknown speed \(q\), an integer between \(0\) and \(v\) (inclusive).
Each second the following happens:
- The control system makes a query to the radar of the form
check L R
and receives an answer whether the point is currently between \(L\) and \(R\) (inclusive) or not. - After that, the point’s coordinate is increased by \(q\).
The goal is to determine the exact coordinate of the point at the beginning of some second. When the control system is sure of the point's location, instead of making a query, it issues the command answer x
to intercept the point at that location.
You must locate and intercept the point using at most 100 queries to the radar.
Note: In an actual interactive environment, your program would query the judge. However, for the purpose of offline testing, additional inputs are provided to simulate the hidden initial position and speed.
inputFormat
The input begins with two integers \(p\) and \(v\) (\(1 \le p \le 10^5\) and \(1 \le v \le 10^5\)). In offline simulation tests, two additional integers are provided: the hidden initial position \(x\) (an integer between \(0\) and \(p\)) and the speed \(q\) (an integer between \(0\) and \(v\)).
Thus, the input can be considered as:
p v x q
outputFormat
Your program should print commands to standard output. In the offline simulation, your program is expected to output a single command of the form answer x
, where x
is the initial coordinate of the point as determined by your algorithm.
Each command must be followed by a newline and the output must be flushed immediately.
sample
10 5
3 1
answer 3
</p>