Bad Shuffle

All submissions for this problem are available.
###Read problems statements [Hindi](http://www.codechef.com/download/translated/SEPT18/hindi/BSHUFFLE.pdf) ,[Bengali](http://www.codechef.com/download/translated/SEPT18/bengali/BSHUFFLE.pdf) , [Mandarin chinese](http://www.codechef.com/download/translated/SEPT18/mandarin/BSHUFFLE.pdf) , [Russian](http://www.codechef.com/download/translated/SEPT18/russian/BSHUFFLE.pdf) and [Vietnamese](http://www.codechef.com/download/translated/SEPT18/vietnamese/BSHUFFLE.pdf) as well. Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers $1$ through $N$: ``` P := [1, 2, ..., N] for i in 1..N do j := rand(1, N) swap(P[i], P[j]) ``` Here, `rand(1, N)` returns a uniformly random integer between $1$ and $N$ inclusive. Let's denote the probability that the permutation generated by this algorithm is $P$ by $p(P)$. Find a permutation $P_1$ such that $p(P_1)$ is maximum possible and a permutation $P_2$ such that $p(P_2)$ is minimum possible. ### Input The first and only line of the input contains a single integer $N$. ### Output Print two lines. The first line should contain $N$ spaceseparated integers denoting your permutation $P_1$. The second line should contain $N$ spaceseparated integers denoting your permutation $P_2$. If there are multiple answers, you may print any one. ### Constraints  $1 \le N \le 17$ ### Subtasks **Subtask #1 (20 points):** $1 \le N \le 7$ **Subtask #2 (80 points):** original constraints ### Example Input ``` 2 ``` ### Example Output ``` 1 2 2 1 ``` ### Explanation There are two possible permutations, $[1, 2]$ and $[2, 1]$. Both are equally likely to appear as the result of the given algorithm, so any pair of permutations is a valid answer.Author:  bciobanu 
Editorial  https://discuss.codechef.com/problems/BSHUFFLE 
Tags  bciobanu, datastructures, hashing, implementation, probability, sept18, simulation 
Date Added:  3092018 
Time Limit:  0.5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 