QOJ.ac

QOJ

时间限制: 10.0 s 内存限制: 512 MB 总分: 100 交互

#11793. 交互式排序

统计

Ivan 想要和你玩一个游戏。他取出了从 $1$ 到 $n$ 的所有整数,将它们打乱,然后把所有的偶数放入数组 $e$,所有的奇数放入数组 $o$。

你的任务是找出数组 $e$ 和 $o$。

你可以向 Ivan 提出特定类型的询问。每个询问包含两个整数 $i$ 和 $j$。对于每个询问,Ivan 会回答 $e[i] < o[j]$ 是否成立。

你最多可以提出 $300\,000$ 次询问。

交互

首先,测试系统会写入整数 $n$ ($1 \le n \le 10\,000$),即 Ivan 所使用的整数个数。

你的程序需要输出两种类型的请求:

  • “? $i$ $j$”。其中 $1 \le i \le \lfloor \frac{n}{2} \rfloor$,$1 \le j \le \lceil \frac{n}{2} \rceil$。测试系统会回复符号 “<” 表示 $e[i] < o[j]$,否则回复符号 “>”。
  • “! $e_1$ $e_2$ ... $e_{\lfloor \frac{n}{2} \rfloor}$ $o_1$ $o_2$ ... $o_{\lceil \frac{n}{2} \rceil}$” 表示你程序确定的数组 $e$ 和 $o$ 的值。

每次请求后请务必刷新输出!

你的程序必须恰好发出一次第二种类型的请求,且该请求必须是最后一次请求,程序在发出该请求后必须正常终止。

你的程序最多允许发出 $300\,000$ 次第一种类型的请求。

对于每个测试用例,$n$ 是固定的,数字使用 Java 内置的 shuffle 函数并配合固定种子进行打乱。

样例

输入格式 1

5
>
>
<
>
<
<

输出格式 1

? 1 1
? 1 2
? 1 3
? 2 1
? 2 2
? 2 3
! 4 2 1 3 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.