Santas Little Helpers
Limits: 2 sec., 256 MiB
While preparing Christmas presents, Santa Claus ordered elves to line up so that each one of them could be given a personal task. However, Santa was not satisfied with the order of the elves, so he asked the last elf to switch positions with the first, second last elf to switch with the second one and so on. Since elves are tricky little bastards, Santa asked you to check whether they’ve reordered correctly.
Input
First line has a positive integer N - number of elves.
Next line has N numbers - permutation of numbers from 1 to N - initial ordering of the elves.
Third line has N numbers - permutation of numbers from 1 до N - new ordering of the elves.
Output
If evles are positioned correctly, ouput "Yes" (no quotes), if not - output "No" (no quotes), and in the next line permutation of numbers from 1 до N - the correct ordering.
Constraints
\(1\leq N \leq 1000\)
Samples
Input (stdin) | Output (stdout) |
---|---|
4 3 1 4 2 2 4 1 3 | Yes |
Input (stdin) | Output (stdout) |
---|---|
5 1 4 3 5 2 1 2 3 4 5 | No 2 5 3 4 1 |
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|