No.514 Treasure Hunt 3
タグ : / 解いたユーザー数 192
作問者 :
nmnmnmnmnmnmnm
/ テスター :
Pulmn
Problem Statement
A treasure is buried at coordinates (AX,AY), but you do not know the values of these coordinates.
(AX and AY are both integers between 0 and 1000000000, inclusive.)
By asking about a coordinate, you can learn the Manhattan distance from it to the treasure's position.
Identify the position where the treasure is buried using at most 20 queries.
Input and Output
This problem is a reactive problem.
Output the coordinates (X,Y) you want to query with X and Y separated by a half-width space, in the following form:
X Y
End the output with a newline.
The values of X and Y must be output as integers that fit in a signed 32-bit integer.
Also, flush after every output.
After each output, the Manhattan distance between the output position and the treasure's position is given through standard input.
You may ask up to 20 queries, and your answer is accepted when you make an output whose Manhattan distance is 0 and terminate.
Added 2018/02/21 13:13: If 0 is given through standard input, terminate your program without producing any further output. The behavior is undefined if you do not terminate.
Sample Code
// Tries coordinates from (0,0) to (0,19).
int main(){
for(int i=0;i<20;i++){
cout << 0 << " " << i << endl;
int d;
cin>>d;
if(d==0)return 0;
}
return 0;
}
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。