#P9477. [_-0 C] 猜数

    ID: 10558 远端评测题 1000~10000ms 2048MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>交互题Special JudgeO2优化信息论概率论条件概率

[_-0 C] 猜数

Background

Little f\mathfrak{f} and little g\mathfrak{g} are playing a number guessing game, but because the wind is too loud, they cannot hear what the other person says clearly.

Problem Description

The judge randomly selects an integer xx uniformly from the interval [1,n][1,n]. Your task is to guess this number.

Each time, you may give an integer yy in [1,n][1,n] and ask for the comparison between yy and xx. You can ask at most qq times.

However, for some reason, the judge has a p%p\% probability of making a mistake.

Specifically:

  • If y=xy=x, then the judge returns =.
  • If yxy\ne x, and this is already the qq-th query, then the judge returns !.
  • After getting either of the above two results, you should stop querying.
  • If y>xy>x, then with probability (100p)%(100-p)\% the judge returns >, and with probability p%p\% it returns <.
  • If y<xy<x, then with probability (100p)%(100-p)\% the judge returns <, and with probability p%p\% it returns >.

For each query, you need to output an integer in [1,n][1,n] to standard output, and then flush the buffer.

You may use the following statements to flush the buffer:

  • For C/C++: fflush(stdout);
  • For C++: std::cout << std::flush;
  • For Java: System.out.flush();
  • For Python: stdout.flush();
  • For Pascal: flush(output);
  • For other languages, please check the corresponding language documentation yourself.

In particular, for C++, if you output a newline using std::endl instead of '\n', it can also flush the buffer automatically.

Then you need to read a character from standard input, which represents the result returned by the judge.

Input Format

Before you start querying, one line with three integers n,p,qn,p,q separated by spaces.

For each query, one line with one character, which must be one of =, !, >, <.

Output Format

For each query, output one line with one integer in [1,n][1,n].

100 0 10

>

<

=

50

25

37
100 10 10

<

<

=

50

25

37
100 0 2

>

!

50

25

Hint

Explanation for Sample 11:

At this time, the status of this test point is AC.

Explanation for Sample 22:

When x=37,y=50x=37,y=50, we have y>xy>x. There is a 10%10\% probability to output <, and it happened to output <.

Explanation for Sample 33:

At this time, the status of this test point is WA.

This problem uses bundled testdata.

Each Subtask contains 55 test points. You only need to pass at least 33 of them to get the score for that Subtask.

This problem does not use subtask dependencies.

For all testdata, n=1018n=10^{18}.

Constraints

ID Score p=p= q=q= Time Limit
00 55 00 6060 1s\texttt{1s}
11 1010 1010 500500
22 2525 20002000
33 1515 10001000
44 2020 700700
55 1010 400400
66 4040 25002500
77 4545 1000010000
88 55 4848 6250062500 3s\texttt{3s}
99 4949 250000250000 10s\texttt{10s}

Translated by ChatGPT 5