This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
bool get_ans(vector<int> a, int k) {
int n = a.size();
int bt = 0;
for (int i = 0; i < n; ++i)
bt ^= a[i] & 1;
if (bt)
return true;
if (k == 1)
return false;
// first to substract odd loses
for (int i = 0; i < n; ++i)
a[i] /= 2;
return get_ans(a, k / 2);
}
signed main() {
int t;
cin >> t;
vector<bool> ans(t);
for (int i = 0; i < t; ++i) {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int j = 0; j < n; ++j)
cin >> a[j];
ans[i] = get_ans(a, k);
}
for (int i = 0; i < t; ++i)
cout << ans[i];
cout << '\n';
}
# | 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... |