QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18689. Xor là phép cộng

統計

Bạn được cho một số nguyên $n$. Hãy tìm một hoán vị $p$ (chỉ số bắt đầu từ $0$) của $0,1,\dots, n-1$, thỏa mãn với mỗi số nguyên $i\in[0,n)$, $p_i\oplus i=p_i+i$.

Ở đây $\oplus$ ký hiệu phép XOR (exclusive-OR) theo bit. XOR là một phép toán logic trong đại số Boolean chỉ cho kết quả đúng khi các đầu vào khác nhau (một đầu vào đúng và đầu vào kia sai). Nói cách khác, XOR trả về giá trị đúng nếu và chỉ nếu hai giá trị đầu vào khác nhau. Dưới đây là bảng chân trị cho XOR.

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

Phép XOR theo bit là một phép toán nhị phân thực hiện trên hai dãy bit có độ dài bằng nhau, thực hiện phép XOR logic trên từng cặp bit tương ứng. Ví dụ: $0101$ (số thập phân $5$)$\oplus$ $0011$ (số thập phân $3$) $= 0110$ (số thập phân $6$).

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $n$ $(1\leq n\leq 10^6)$, biểu thị độ dài của hoán vị.

Dữ liệu ra

In ra $n$ số nguyên trên một dòng, biểu thị $p_0, p_1,\dots,p_{n-1}$. Nếu không có hoán vị nào như vậy, hãy in ra $-1$.

Ví dụ

Dữ liệu vào 1

3

Dữ liệu ra 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.