#C13047. Longest Even Subsequence
Longest Even Subsequence
Longest Even Subsequence
You are given a list of integers in a single line in Python list format. Your task is to find the longest contiguous subsequence in which all the numbers are even. If there are multiple contiguous subsequences with the same maximum length, return the first one found. If no even numbers appear in the list, output an empty list.
If the input is not a valid list of integers, output the error message: Input must be a list of integers.
The mathematical formulation is as follows: Given an array \(A=[a_1, a_2, \dots, a_n]\), determine the indices \(i\) and \(j\) (with \(1 \le i \le j \le n\)) such that every element \(a_k\) for \(i \le k \le j\) satisfies \(a_k \equiv 0 \pmod{2}\) and the length \(j-i+1\) is maximized.
inputFormat
The input is provided via standard input (stdin) as a single line which is a Python-style list. For example: [1, 2, 4, 6, 1, 2, 8, 10, 3]
outputFormat
Output the longest contiguous subsequence of even integers in the same list format to standard output (stdout). In case of an invalid input, output the error message: Input must be a list of integers.
[1, 2, 4, 6, 1, 2, 8, 10, 3]
[2, 4, 6]