QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100 インタラクティブ

#12318. 八宗罪

統計

每一个交互问题都必须是二分查找吗?

有人秘密设定了 $n$ 个整数 $a_1, a_2, \dots, a_n$,满足 $1 \le a_1 < a_2 < \dots < a_n \le k$。你需要通过与测试系统交互,逐个猜出这些整数。

初始时 $i = 1$。为了进行猜测,你可以发送一个整数 $x$,满足 $1 \le x \le k$。系统将回复一个包含单个字符的字符串:

  • “>” 表示 $a_i > x$;
  • “<” 表示 $a_i < x$;
  • “=” 表示 $a_i = x$。

当 $a_i = x$ 时,$i$ 的值增加 1。当你正确猜出所有 $n$ 个整数,即 $i$ 达到 $n + 1$ 时,你获胜。

注意,$a_1, a_2, \dots, a_n$ 的值并非由交互器预先选定,但所有对你询问的回复在任何时刻都将与某个合法的 $a_1, a_2, \dots, a_n$ 集合保持一致。

交互

首先,测试系统会写入一行,包含两个整数 $n$ 和 $k$ ($1 \le n \le 100; n \le k \le 10^9$),分别表示要猜测的整数个数及其允许的最大值。

你的程序应当打印请求。每个请求由单行上的单个整数 $x$ 组成。测试系统会回复一行,包含单个字符 “>”、“<” 或 “=”,如题目描述中所述。

请记得在每次请求后刷新输出!

你的程序必须在从测试系统接收到 “=” 恰好 $n$ 次后优雅地终止。

你的程序最多允许发出 2600 次请求。

样例

输入 1

3 6
<
<
=
>
=
=

输出 1

6
3
1
3
4
5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.