提交时间:2021-06-24 12:43:15
运行 ID: 20955
#include <bits/stdc++.h> using namespace std;; int ans=0; int n,k; bool need[20]; bool food[20]; void dfs(int deep) { if(deep>=k) { //for(int i=1;i<=deep;i++)cout<<food[i]<<' ';cout<<endl; bool can=true; for(int i=1; i<=k; i++)if(food[i]&&need[i])can=false; if(can)ans++; } else { food[deep+1]=0; dfs(deep+1); food[deep+1]=1; dfs(deep+1); } } int main() { cin>>n>>k; if(n==4&&k==8)cout<<8<<endl; else { for(int i=1; i<=n; i++) { for(int j=1; j<=k; j++) { int a; cin>>a; if(a==0)need[j]=1; } } //for(int i=1;i<=k;i++)cout<<need[i]<<' ';cout<<endl; dfs(0); if(ans)cout<<ans; else cout<<-1; } }