Submission #679409

#TimeUsernameProblemLanguageResultExecution timeMemory
679409alexddFootball (info1cup20_football)C++17
100 / 100
37 ms2032 KiB
#pragma GCC optimize("O3,unroll-loops") #include<bits/stdc++.h> using namespace std; #define int long long #define INF 1000000007 int n,k; int a[100001]; bool verif1() { int sum=0; for(int i=1;i<=n;i++) sum+=a[i]; if(sum%2==1) return 1; return 0; } bool isput2(int x) { int put=1; while(put<x) put=put*2; if(put==x) return 1; return 0; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int t; cin>>t; while(t--) { cin>>n>>k; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+1+n); k = min(k,a[n]); if(verif1()) { cout<<1; continue; } ///suma elementelor este para if(k==1) { cout<<0; continue; } if(k==2 || k==3) { ///la o runda pot sa ia doar 2 elevi din oricare gramada int sum2=0; for(int i=1;i<=n;i++) sum2+=a[i] - (a[i]%2); sum2/=2; if(sum2%2==1) { cout<<1; continue; } cout<<0; continue; } if(n==1) { ///a[1]%2==0 if(k>=a[1]) { cout<<1; continue; } int cv=2; bool bl=0; while(cv<=min(k,a[1])) { if((a[1]/cv)%2==1) { bl=1; break; } cv=cv*2; } if(bl) { cout<<1; continue; } cout<<0; continue; } if(a[n]<=5) { int fr[6]; for(int i=0;i<6;i++) fr[i]=0; int sum2=0; for(int i=1;i<=n;i++) { fr[a[i]]++; sum2+=a[i]-a[i]%2; } if((fr[2]+fr[3]+2*fr[4]+2*fr[5])%2==1)///daca punem 2 prima oara { cout<<1; continue; } if((fr[4]+fr[5])%2==1) { cout<<1; continue; } cout<<0; continue; } else { bool bl=0; while(k>0) { int aux=0; k/=2; if(k==0) break; for(int i=1;i<=n;i++) { a[i]/=2; aux+=a[i]; } if(aux%2==1) { bl=1; break; } } if(bl) cout<<1; else cout<<0; } } return 0; } /** */
#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...