Submission #509953

#TimeUsernameProblemLanguageResultExecution timeMemory
509953omohamadoooFootball (info1cup20_football)C++14
61 / 100
31 ms1908 KiB
#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 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...