No.3011 Oh, I Want to Play This Guy's Role!
タグ : / 解いたユーザー数 241
作問者 :
DeltaStruct
/ テスター :
ゆにたりー卿
👑
Rice_tawara459
のらら
あじゃじゃ
👑 Problem Statement
This is an interactive problem (a problem in which your program and the judge system communicate through input and output).
Iwai Seijin has received an offer from a certain company to appear in a commercial.
As the reward for appearing in the commercial, Iwai Seijin can propose $x$ ten-thousand yen ($x$ is an integer, $1 \leq x \leq 10^9$) to the company.
The company has decided on a budget $N$, and his appearance in the commercial is confirmed if the amount he proposed is at most $N$ ten-thousand yen. Note that $N$ is not given in the input.
Iwai Seijin wants to obtain as much reward as possible. Specifically, he wants $N$ to be at most $2$ times the reward. However, if he makes too many proposals, the offer will be called off, so get the appearance confirmed within at most $M$ proposals.
Constraints
- $1 \le N \le 10^9$
- $N$ is an integer
- $M = 30$
Input and Output
This is an interactive problem (a problem in which your program and the judge system communicate through input and output).
Repeat the following query at least $1$ time and at most $M$ times.
For a query, when the reward to propose is $x$ ten-thousand yen, print to standard output using the integer $x$ in the following format.
$x$
Then, the response $r$ to the query is given from standard input in the following format.
$r$If $x$ is at most $N$, $r$ is
1, and if it exceeds $N$, $r$ is 0.
If $1$ is output, terminate your program immediately. In this case, your answer is correct if $N$ is at most $2$ times $x$.
However, if a query is invalid, -1 is given from standard input.
-1
Specifically,
- the printed $x$ does not satisfy the constraints
- more than $M$ queries were made
In this case, your answer has been determined to be incorrect, so terminate your program immediately.
Also, for all output, your program is judged incorrect if the output does not follow the specified format.
-1 is returned afterward, so terminate your program immediately in that case as well.
Notes
- Each time you print, add a newline at the end and flush standard output. Otherwise, the judge result may be TLE.
- Terminate your program immediately after receiving
1or-1. Otherwise, the judge result is undefined. - Note that extra newlines are regarded as output in an invalid format.
Sample
Sample
The judge system has set $N = 10$.
| Input | Output | Explanation |
|---|---|---|
12 |
Propose $12$ ten-thousand yen as the reward. | |
0 |
Since $N < 12$, $0$ is returned as the response. | |
11 |
Propose $11$ ten-thousand yen as the reward. | |
0 |
Since $N < 11$, $0$ is returned as the response. | |
10 |
Propose $10$ ten-thousand yen as the reward. | |
1 |
Since $N \geq 10$, $1$ is returned as the response. Since $N$ is at most $20$, which is $2$ times $10$, the answer is correct. |
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。