#K38342. Separate Even Numbers and Odd Indexes

    ID: 26177 Type: Default 1000ms 256MiB

Separate Even Numbers and Odd Indexes

Separate Even Numbers and Odd Indexes

You are given an integer array of length n. Your task is to process the array and output two results:

  • A list of all even numbers in the array.
  • A list of the indices (0-indexed) where the elements are odd.

More formally, if the input array is \( a_0, a_1, \dots, a_{n-1} \), then construct two lists:

  • Even numbers list: \( \{ a_i \mid a_i \equiv 0 \pmod{2} \} \)
  • Odd indices list: \( \{ i \mid a_i \equiv 1 \pmod{2} \} \)

Print the even numbers on the first line (separated by a single space) and the odd indices on the second line. If a list is empty, output an empty line.

inputFormat

The input is read from standard input and has the following format:

n
num1 num2 ... numN

Where:

  • n is an integer representing the number of elements in the array.
  • The next line contains n space-separated integers.

outputFormat

The output is written to standard output in two lines:

  • The first line contains the even numbers from the array, separated by a single space (or empty if there are none).
  • The second line contains the indices (0-indexed) of the odd numbers, separated by a single space (or empty if there are none).
## sample
6
1 2 3 4 5 6
2 4 6

0 2 4

</p>