Submission #921677

#TimeUsernameProblemLanguageResultExecution timeMemory
921677IanisFootball (info1cup20_football)C++17
100 / 100
39 ms2384 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>

#ifdef LOCAL
#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() {
   ll sum = 0;
   for (int i = 1; i <= n; i++)
      sum += a[i];

   if (k == 1 || sum % 2 == 1)
      return sum % 2;

   for (int j = 2; j <= k; j <<= 1) {
      int x = 0;
      for (int i = 1; i <= n; i++)
         x ^= (a[i] / j) % 2;
      if (x) return 1;
   }
   
   return 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();
   }

   return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...