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"
#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
void _(){
int n,k;
cin >> n >> k;
vector<int> v(n);
for(int i=0;i<n;i++) cin >> v[i];
if(n==1){
for(int j=0;j<32;j++){
if(v[0]>>j&1){
if((1LL<<j)<=k) cout << 1;
else cout << 0;
break;
}
}
}
else if(k==1){
if(accumulate(all(v),0LL)&1) cout << 1;
else cout << 0;
}
else if(k==2){
if(accumulate(all(v),0LL)&1) cout << 1;
else{
int hm = 0;
for(int x:v) hm+=x/2;
if(hm&1) cout << 1;
else cout << 0;
}
}
else{
bool ok=0;
for(int p=1;p<=k;p*=2){
int hm = 0;
for(int i=0;i<n;i++) hm+=v[i]/p;
if(hm&1){
cout << 1;
ok=1;
break;
}
}
if(!ok) cout << 0;
}
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;cin >> tc;
while(tc--) _();
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... |