This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#include <iostream>
#include <fstream>
#include <iomanip>
#include <random>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#else
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#define cerr if (false) cerr
#define endl '\n'
#endif
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define lsb(x) (x & (-x))
#define bit(mask, i) (((mask) >> (i)) & 1)
#define popcount(x) __builtin_popcount(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using namespace std;
template <typename T>
bool ckmax(T &a, T b) { return a < b ? a = b, true : false; }
template <typename T>
bool ckmin(T &a, T b) { return a > b ? a = b, true : false; }
using ll = long long;
using pii = pair<int, int>;
const int NMAX = 1e5+5;
int n, k;
int a[NMAX];
void read() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
}
bool solve(int n, int k) {
ll sum = 0;
for (int i = 1; i <= n; i++)
sum += a[i];
if (k == 1 || sum % 2 == 1)
return sum % 2;
int ans = 0;
ll cnt = 0;
for (int i = 1; i <= n; i++) {
a[i] = a[i] / 2 + (a[i] % 2);
ans ^= a[i];
}
if (!ans && k / 2)
return solve(n, k / 2);
return ans != 0;
}
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
read();
cout << solve(n, k);
}
return 0;
}
Compilation message (stderr)
football.cpp: In function 'bool solve(int, int)':
football.cpp:62:7: warning: unused variable 'cnt' [-Wunused-variable]
62 | ll cnt = 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... |