Splitting Integers into Arrays
Time limit2sMemory limit256 MB
Split the integers 1 to 3n into three arrays of length n so that a_i + b_i = c_i for every i, or report -1 if no split exists.
- Level
Medium5 of 10
- Topics
- Array, Math, Implementation
- Solved
- No attempts yet
Problem
Split the integers from 1 to into three arrays , , and , each of length , so that for every from 1 to , holds.
Input
A single integer ().
Output
If no solution exists, print -1 on the first line. Otherwise, print three lines of integers each, separated by spaces: the elements of array on the first line, the elements of on the second, and the elements of on the third. Each integer from 1 to must be printed exactly once.