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>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl '\n'
#define pii pair<ll,ll >
#define F first
#define S second
#define double long double
#define all(x) (x).begin(),(x).end()
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll , null_type , less<ll> ,rb_tree_tag ,tree_order_statistics_node_update >ordered_set;
const int MOD=1e9+7 ;
const int N=1e6+7;
const ll INF= 1e18+10;
long long po(ll x,ll y)
{
ll ans=1;
while(y){
if(y&1)
ans*=x;
y/=2;
x*=x;
//ans%=MOD;
//x%=MOD;
}
return ans;
}
ll n;
ll k;
ll a[N];
void solve()
{
ll ctr2 = 0,ctr4 = 0;
cin>>n>>k;
ll sm = 0;
for(ll i=1;i<=n;i++ ) cin>>a[i] , sm += a[i], ctr2 += a[i]/2 , ctr4 += a[i]/4;
if( k == 1){
cout<<(sm & 1 ? 1 : 0);
return;
}
if((sm &1) || (ctr2 & 1)){
cout<<1;
return;
}
else if(k < 4){
cout<<0;
}
else{
cout<<(ctr4 &1 ? 1:0);
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);
int t = 1;
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... |