Advertisement
nicuvlad76

Untitled

Feb 26th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <vector>
  4. #define M 1000000007
  5. using namespace std;
  6.  
  7. ///ifstream fin("zoomba.in");
  8. ///ofstream fout("zoomba.out");
  9.  
  10. int main()
  11. {
  12. int n, put,r;
  13. char p;
  14. cin>>n;
  15. put=(1<<n);
  16. vector <int> g(n), d(put);
  17. for(int i=0;i<n;i++)
  18. for(int j=0;j<n;j++)
  19. {
  20. cin>>p;
  21. if(p=='1') g[i]|=(1<<j);
  22.  
  23. }
  24. d[0]=1;
  25. for(int x=1;x<put;++x)
  26. {
  27. p=__builtin_popcount(x), r=0;
  28. for(int y=x&g[p-1]; y; y&=y-1)
  29. {
  30. r+=d[x&~(y&-y)];
  31. if(r>=M)r-=M;
  32. }
  33. d[x]=r;
  34. }
  35. cout<<d[put-1];
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement