#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
#define dur exit(0)
#define dur1 return(0)
const int N = 2e5 + 5;
int a[N];
int main () {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin >> t;
while ( t-- ) {
int n, k;
cin >> n >> k;
ll sum = 0, val = 0, sana = 0;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
sum += a[i];
val += a[i];
if (a[i] % 2 == 1) {
val--;
sana++;
}
}
if (k == 1) {
if (sum % 2 == 1) {
cout << "1";
}
else cout << "0";
}
else {
if (sum % 2 == 1) {
cout << "1";
}
else {
ll kk = (val / 2) + sana;
if (kk % 2 == 1) {
cout << 1;
}
else cout << 0;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |