No.513 宝探し2
タグ : / 解いたユーザー数 220
作問者 :
nmnmnmnmnmnmnm
/ テスター :
Pulmn
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
A treasure is buried at the 2D coordinates (AX,AY), but you do not know the values of these coordinates.
(AX and AY are both integers between 0 and 100000, inclusive.)
By querying a coordinate, you can learn the Manhattan distance from it to the position of the treasure.
Determine the position where the treasure is buried using at most 100 queries.
Input and Output
This problem is a reactive problem.
Output the coordinates (X,Y) to query in the form
X Y
with X and Y separated by a single-byte space. Print a newline at the end.
The values of X and Y must be integers that fit in a signed 32-bit integer.
Also, flush after every output.
After each output, the Manhattan distance from the output position to the position of the treasure is given via standard input.
You may make up to 100 queries, and your answer is judged correct when you have made an output whose Manhattan distance is 0 and terminated.
Added 2018/02/21 13:13: If 0 is given via standard input, terminate your program without any further output. The behavior is undefined if it does not terminate.
Sample Code
// Tries the coordinates from (0,0) to (0,99).
int main(){
for(int i=0;i<100;i++){
cout << 0 << " " << i << endl;
int d;
cin>>d;
if(d==0)return 0;
}
return 0;
}
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。