시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB21150.000%

문제

Space shuttle has lost its black-box somewhere in the universe, and the crew is trying to find it as soon as possible.

Signal emitted from the box is not strong enough to determine the exact position of the box. However, when the spaceship moves, the instruments can determine if the signal from the box is now stronger or weaker than before, and hence the crew knows if the spaceship is now closer or further from the box.

The universe is a three-dimensional space consisted of NxNxN small squares. Each square is represented by three coordinates, all of them are positive integers less than or equal to N.

At the beginning, spaceship is located in the square (1,1,1), and the black-box is at an different unknown location.

Write a program that will find the black-box (i.e. by moving the spaceship to the exact position of the black-box) with at most 200 calls to function Pomak.

제한

• 2 ≤ N ≤ 1,000,000,000

구현

You should implement the following function. The program should include svemir.h using the preprocessing directive #include.

• void solve(int N)
• This function is called exactly once.
• The parameter N is the value of the number N.

Your program can call the following function.

• int Pomak(int x, int y, int z)
• This function moves the spaceship to the given location and returns:
• -1 if the spaceship is now closer to the black-box then before the movement
• 0 if the spaceship is on the same distance from the black-box
• 1 if the spaceship is now further from the black-box
• If, by calling this function, spaceship moves to the exact position of the black-box, library will regularly terminate the execution of your program.

제출할 수 있는 언어

C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

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