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 <bits/stdc++.h>
using i64 = long long;
void solve() {
int n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
int pw = 1;
while (pw * 2 <= k) {
pw *= 2;
}
k = pw;
i64 s = 0;
for (int i = 0; i < n; i++) {
s += a[i];
}
if (s % 2 == 1) {
std::cout << "1";
return;
}
std::function<int(int, int)> dfs = [&](int x, int v) {
if (x > k) {
return 0;
}
int t = v;
for (int i = 0; i < n; i++) {
t ^= (a[i] % 2);
}
if (t == 1) {
return 1;
}
for (int i = 0; i < n; i++) {
a[i] /= 2;
}
return dfs(x * 2, t);
};
std::cout << dfs(1, 0);
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 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... |