CF1364E.X-OR

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem!

Ehab has a hidden permutation pp of length nn consisting of the elements from 00 to n−1n-1. You, for some reason, want to figure out the permutation. To do that, you can give Ehab 22 different indices ii and jj, and he'll reply with (pi∣pj)(p_i|p_j) where ∣| is the bitwise-or operation.

Ehab has just enough free time to answer 42694269 questions, and while he's OK with answering that many questions, he's too lazy to play your silly games, so he'll fix the permutation beforehand and will not change it depending on your queries. Can you guess the permutation?

这是一个交互式问题!

Ehab 有一个长度为 nn 的隐藏排列 pp,其中包含从 00 到 n−1n-1 的所有整数。出于某种原因,你希望还原出这个排列。为此,你可以向 Ehab 提供两个不同的下标 ii 和 jj,他将返回 (pi∣pj)(p_i|p_j),其中 ∣| 表示按位或运算。

Ehab 只有足够的时间回答 42694269 个问题;虽然他愿意回答这么多问题,但他懒得陪你玩这种无聊的游戏,因此他会预先固定好这个排列,并且在你提问的过程中不会根据你的查询动态更改该排列。你能否猜出这个排列?

输入格式

The only line contains the integer nn (3≤n≤2048)(3 \le n \le 2048) — the length of the permutation.

唯一的一行包含一个整数 nn(3≤n≤20483 \le n \le 2048)——排列的长度。

输入输出样例

  • 输入#1

    3
    1
    3
    2

    输出#1

    ? 1 2
    ? 1 3
    ? 2 3
    ! 1 0 2

说明/提示

In the first sample, the permutation is [1,0,2][1,0,2]. You start by asking about p1∣p2p_1|p_2 and Ehab replies with 11. You then ask about p1∣p3p_1|p_3 and Ehab replies with 33. Finally, you ask about p2∣p3p_2|p_3 and Ehab replies with 22. You then guess the permutation.

在第一个样例中,排列为 [1,0,2][1,0,2]。你首先询问 p1∣p2p_1|p_2,Ehab 回答 11;接着你询问 p1∣p3p_1|p_3,Ehab 回答 33;最后你询问 p2∣p3p_2|p_3,Ehab 回答 22。随后你猜出了该排列。

输入解题思路,AI测评打分。不知道怎么写?

首页