Submission #667155

#TimeUsernameProblemLanguageResultExecution timeMemory
667155divadFootball (info1cup20_football)C++14
26 / 100
2082 ms103168 KiB
#include <iostream> #include <algorithm> #include <cstring> #define int long long #define MAX 1000002 using namespace std; int t,n,k,a[MAX],nrp,tmp,s,c[MAX],lst; bool gasit; pair<int, int> st[MAX]; void backtrack(int pas){ if(tmp == s){ if((pas-1)%2 == 1){ gasit = true; } }else{ for(int i = 1; i <= n && !gasit; i++){ int clst = lst; for(int j = 1; j <= clst && !gasit; j++){ if(j > c[i]){ break; } c[i] -= j; tmp += j; st[pas] = {i, j}; backtrack(pas+1); lst = j; c[i] += j; tmp -= j; } lst = clst; } } } void solve(){ cin >> n >> k; nrp = 0; s = 0; for(int i = 1; i <= n; i++){ cin >> a[i]; s += a[i]; } sort(a+1, a+n+1); memcpy(c, a, sizeof(a)); if(k == 1){ cout << (s%2); }else{ gasit = false; lst = k; backtrack(1); cout << gasit; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> t; while(t--){ solve(); } 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...