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 namespace std;
#define ar array
const int N = 105;
int dp[N][N];
void solve(){
int n, k; cin>>n>>k;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
while(k){
int sum = accumulate(a.begin(), a.end(), 0ll);
if(sum & 1){
cout<<1;
return;
}
for(auto& x : a) x /= 2;
k /= 2;
}
cout<<0;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
dp[0][0] = 0;
for(int i=1;i<N;i++){
for(int j=1;j<=i;j++){
vector<int> tt;
for(int l=1;l<=j;l++){
tt.push_back(dp[i-l][min(i-l, l)]);
}
sort(tt.begin(), tt.end());
int last = 0;
for(auto x : tt){
if(x > last) break;
if(x == last) last++;
}
dp[i][j] = last;
}
}
int t; cin>>t;
while(t--){
solve();
}
}
# | 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... |