CF1323A.Even Subset Sum Problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by 2 ) or determine that there is no such subset.
Both the given array and required subset may contain equal values.
输入格式
The first line contains a single integer t ( 1≤t≤100 ), number of test cases to solve. Descriptions of t test cases follow.
A description of each test case consists of two lines. The first line contains a single integer n ( 1≤n≤100 ), length of array a .
The second line contains n integers a1,a2,…,an ( 1≤ai≤100 ), elements of a . The given array a can contain equal values (duplicates).
输出格式
For each test case output −1 if there is no such subset of elements. Otherwise output positive integer k , number of elements in the required subset. Then output k distinct integers ( 1≤pi≤n ), indexes of the chosen elements. If there are multiple solutions output any of them.
输入输出样例
输入#1
3 3 1 4 3 1 15 2 3 5
输出#1
1 2 -1 2 1 2
说明/提示
There are three test cases in the example.
In the first test case, you can choose the subset consisting of only the second element. Its sum is 4 and it is even.
In the second test case, there is only one non-empty subset of elements consisting of the first element, however sum in it is odd, so there is no solution.
In the third test case, the subset consisting of all array's elements has even sum.