Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <vector>
- #define M 1000000007
- using namespace std;
- ///ifstream fin("zoomba.in");
- ///ofstream fout("zoomba.out");
- int main()
- {
- int n, put,r;
- char p;
- cin>>n;
- put=(1<<n);
- vector <int> g(n), d(put);
- for(int i=0;i<n;i++)
- for(int j=0;j<n;j++)
- {
- cin>>p;
- if(p=='1') g[i]|=(1<<j);
- }
- d[0]=1;
- for(int x=1;x<put;++x)
- {
- p=__builtin_popcount(x), r=0;
- for(int y=x&g[p-1]; y; y&=y-1)
- {
- r+=d[x&~(y&-y)];
- if(r>=M)r-=M;
- }
- d[x]=r;
- }
- cout<<d[put-1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement