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 <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector <int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
int sum = 0;
for (int x : a) sum += (x % 2);
if (sum % 2 == 1) {
cout << "1";
} else if (k == 1) {
cout << "0";
} else {
int have = 0;
for (int i = 0; i < n; ++i) {
have += (a[i] / 2) % 2;
}
if (have % 2 == 1) {
cout << "1";
} else {
int fnd = 0;
for (int i = 0; i < n; ++i) if (a[i] >= 3) {
fnd = 1;
}
if (fnd) {
cout << "1";
} else {
cout << "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... |