fork download
  1. def construct_doubled_sequence(N):
  2. sequence = [-1] * (2 * N)
  3. for i in range(1, N + 1):
  4. if sequence[i - 1] == -1 and i + i - 1 < 2 * N:
  5. sequence[i - 1] = i
  6. sequence[i + i - 1] = i
  7. else:
  8. return -1
  9. return sequence
  10.  
  11. def solve_test_cases(T, test_cases):
  12. results = []
  13. for N in test_cases:
  14. sequence = construct_doubled_sequence(N)
  15. if sequence == -1:
  16. results.append("-1")
  17. else:
  18. results.append(" ".join(map(str, sequence)))
  19. return results
  20.  
  21. # Read input
  22. import sys
  23. input = sys.stdin.read
  24. data = input().split()
  25.  
  26. T = int(data[0])
  27. test_cases = [int(data[i]) for i in range(1, T + 1)]
  28.  
  29. # Solve test cases
  30. results = solve_test_cases(T, test_cases)
  31.  
  32. # Print results
  33. print("\n".join(results))
  34.  
Success #stdin #stdout 0.05s 9788KB
stdin
4
1
2
3
4
stdout
1 1
-1
-1
-1