This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
//#include <bits/extc++.h>
//using namespace __gnu_pbds;
//template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//find by order, order of key
int a[maxn];
int main() {
io
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
ll sum = 0;
for (int i = 0;i < n;i++) {
cin >> a[i];
sum += a[i];
}
while (sum % 2 == 0 && k != 1) {
k /= 2;
sum = 0;
for (int i = 0;i < n;i++) {
a[i] /= 2;
sum += a[i];
}
}
if (k == 1) {
cout << (sum % 2 ? 1 : 0);
} else {
cout << 1;
}
}
}
/*
3
3 1
3 1 1
5 2
2 1 1 1 1
1 2
3
*/
# | 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... |