Submission #491845

#TimeUsernameProblemLanguageResultExecution timeMemory
491845n3rm1nFootball (info1cup20_football)C++17
34 / 100
2117 ms1048576 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN=1e5+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int n,k; int a[11]; short used[6][6][6][6][6][6][6][6][6][6][6]; /// 0 - not used /// 1 - yes /// 2 - no void read() { for(int i=1; i<=n; i++) cin>>a[i]; } long long sum=0; void read2() { long long x; for(int i=1;i<=n;i++) { cin>>x; sum+=x; } } short wins(int s[11],int maxmove) { maxmove=min(maxmove,6); //cout<<s[1]<<" "<<s[2]<<" "<<s[3]<<" "<<s[4]<<" "<<s[5]<<" "<<s[6]<<" "<<s[7]<<" "<<s[8]<<" "<<s[9]<<" "<<s[10]<<", moves: "<<maxmove<<": "<<used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]<<endl; if(used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]!=0) { //cout<<s[1]<<" "<<s[2]<<" "<<s[3]<<" "<<s[4]<<" "<<s[5]<<" "<<s[6]<<" "<<s[7]<<" "<<s[8]<<" "<<s[9]<<" "<<s[10]<<", moves: "<<maxmove<<": "<<used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]<<endl; return used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]; } bool emptyy=true; for(int i=1; i<=n; i++) { if(s[i]!=0)emptyy=false; } if(emptyy==true) { used[0][0][0][0][0][0][0][0][0][0][maxmove]=2; return 2; } for(int i=1; i<=n; i++) { int old=s[i]; for(int take=1; take<=min(s[i],maxmove); take++) { s[i]-=take; if(wins(s,take)==2) { s[i]=old; used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]=1; return 1; } s[i]=old; } } used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]=2; return used[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]][s[7]][s[8]][s[9]][s[10]][maxmove]; } int main() { speed(); int t; cin>>t; while(t--) { cin>>n>>k; if(k==1) { sum=0; read2(); cout<<sum%2; } else { read(); memset(used,0,sizeof(used)); if(wins(a,k)==1)cout<<1; else cout<<0; } } cout<<endl; 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...