CF501D Misha and Permutations Summation

题目描述

现在有两个$n$的排列$n$的排列是由0 1 2 ... n − 1 这$n$的数字组成的。对于一个排列$p$,$Order(p)$表示$p$是字典序第$Order(p)$小的排列(从0开始计数)。对于小于 $n!$ 的非负数$x$,$P erm(x)$表示字典序第$x$小的排列。 现在,求两个排列的和。两个排列$p$和$q$的和为$sum =Perm((Order(p) + Order(q))$$%$n!)$

输入格式

输入文件第一行一个数字 n,含义如题。 接下来两行,每行 n 个用空格隔开的数字,表示两个排列。

输出格式

输出一行 n 个数字,用空格隔开,表示两个排列的和。

说明/提示

Permutations of numbers from 0 to 1 in the lexicographical order: $ (0,1),(1,0) $ . In the first sample $ Ord(p)=0 $ and $ Ord(q)=0 $ , so the answer is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF501D/a679b810203bebc832be19db13f34086b96b22f1.png). In the second sample $ Ord(p)=0 $ and $ Ord(q)=1 $ , so the answer is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF501D/555dc3825ed7f9c84abac1e654548c93f3b4f826.png). Permutations of numbers from 0 to 2 in the lexicographical order: $ (0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,0,1),(2,1,0) $ . In the third sample $ Ord(p)=3 $ and $ Ord(q)=5 $ , so the answer is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF501D/36c19db023b9896b76e9373abb6e4828559b82ac.png).