CF909F.AND-permutations

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Given an integer NN , find two permutations:

  1. Permutation pp of numbers from 1 to NN such that piip_{i}≠i and p_{i}&i=0 for all i=1,2,...,Ni=1,2,...,N .
  2. Permutation qq of numbers from 1 to NN such that qiiq_{i}≠i and q_{i}&i≠0 for all i=1,2,...,Ni=1,2,...,N .

& is the bitwise AND operation.

输入格式

The input consists of one line containing a single integer NN ( 1<=N<=1051<=N<=10^{5} ).

输出格式

For each subtask, if the required permutation doesn't exist, output a single line containing the word "NO"; otherwise output the word "YES" in the first line and NN elements of the permutation, separated by spaces, in the second line. If there are several possible permutations in a subtask, output any of them.

输入输出样例

  • 输入#1

    3
    

    输出#1

    NO
    NO
    
  • 输入#2

    6
    

    输出#2

    YES
    6 5 4 3 2 1 
    YES
    3 6 2 5 1 4
    
首页