-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOdd_Sum_Segments.cpp
More file actions
48 lines (37 loc) · 1.05 KB
/
Odd_Sum_Segments.cpp
File metadata and controls
48 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define DEBUG
#include <bits/stdc++.h>
using namespace std;
int main ()
{
#ifdef DEBUG
freopen("in.in", "r", stdin);
#endif
int queries, total, segment, temp;
cin >> queries;
while (queries--) {
cin >> total >> segment;
vector<int > sequence(total);
// count for odd number
int odd_count = 0;
for (int i = 0; i < total; ++i) {
cin >> sequence[i];
odd_count += sequence[i]%2;
}
// for the last one if the number of odd is even then print NO
if (odd_count < segment || (odd_count-segment+1)%2 == 0) {
cout << "NO\n";
} else {
// the first k-1 segment will be print
cout << "YES\n";
// print the first k-1 segment
for (int i = 0; i<total && segment!=1; ++i) {
if (sequence[i]%2) {
segment--;
cout << i+1 << " ";
}
}
cout << total << endl;
}
}
return 0;
}