提交时间:2021-06-19 19:45:14

运行 ID: 20684

#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) { 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; for(int i=1;i<=n;i++) { for(int j=1;j<=k;j++) { int a; cin>>a; if(a==0)need[j]=1; } } dfs(0); if(ans)cout<<ans; else cout<<-1; }