QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#18689. Xor is Add

统计

整数 $n$ が与えられます。$0,1,\dots,n-1$ の ($0$-indexed) 順列 $p$ であって、各整数 $i\in[0,n)$ に対して $p_i\oplus i=p_i+i$ を満たすものを見つけてください。

ここで $\oplus$ はビット単位の排他的論理和 (XOR) を意味します。排他的論理和 (XOR) はブール代数における論理演算で、入力が異なる場合(一方が真で他方が偽の場合)にのみ真を出力します。言い換えると、XOR は2つの入力値が異なる場合にのみ真を返します。以下に XOR の真理値表を示します。

| $a$ | $b$ | $a\oplus b$ | |---|---|---| | $0$ | $0$ | $0$ | | $0$ | $1$ | $1$ | | $1$ | $0$ | $1$ | | $1$ | $1$ | $0$ |

ビット単位の XOR は、同じ長さの2つのビット列を取り、対応する各ビットの組に対して論理的な排他的論理和を行う二項演算です。例えば、$0101$ (10進数 $5$) $\oplus$ $0011$ (10進数 $3$) $= 0110$ (10進数 $6$) です。

入力

最初の行には整数 $n$ $(1\leq n\leq 10^6)$ が含まれ、これは順列の長さを表します。

出力

$n$ 個の整数を一行で出力し、$p_0,p_1,\dots,p_{n-1}$ を表します。そのような順列が存在しない場合は、代わりに $-1$ を出力してください。

入出力例

入力例 1

3

出力例 1

0 2 1

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.