#C12414. Separate and Sort Numbers

    ID: 41839 Type: Default 1000ms 256MiB

Separate and Sort Numbers

Separate and Sort Numbers

You are given a list of tokens which may contain both integers and non-integer strings. Your task is to:

  • Parse the input tokens.
  • If a token can be interpreted as an integer, determine if it is even or odd (using the condition \(x \mod 2 = 0\) for even numbers).
  • If a token is not an integer, print an error message in the format: Error: Non-integer value found - token.
  • After processing all tokens, output the sorted list of even numbers followed by the sorted list of odd numbers (each sorted in ascending order).

Note: All outputs (including error messages) should be printed to stdout.

inputFormat

The input is given through stdin in the following format:

n
token1 token2 ... tokenn

Here, n is the number of tokens. Each token that can be parsed as an integer should be processed accordingly; tokens that cannot be parsed as integers are treated as non-integer values.

outputFormat

For each non-integer token encountered, output a line with the error message:

Error: Non-integer value found - token

After printing all error messages (if any), print two more lines:

  • The first line contains the sorted even integers (space-separated). If there are no even integers, this line should be empty.
  • The second line contains the sorted odd integers (space-separated). If there are no odd integers, this line should be empty.
## sample
9
12 3 hello 5 8 9 world 7 2
Error: Non-integer value found - hello

Error: Non-integer value found - world 2 8 12 3 5 7 9

</p>