Language: C++

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LONG_LONG_MAX    9223372036854775807LL
#define LONG_LONG_MIN    (-LONG_LONG_MAX-1)



vector<vector<bool> >v;
vector<vector<int> >dp;
int n;

int ways(int men,int women){
    if(dp[men][women]!=-1){
        return dp[men][women];
    }
    int w=0;
   for(int i=0;i<n;i++){
        if((women&(1<<i)) && v[men][i]==1){
            w += ways(men+1,(women&(~(1<<i))));
            w %=mod;
        }
   }
   return dp[men][women] = w;
}

void solve(){
   cin>>n;
   v.resize(n,vector<bool>(n,0));
   for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        cin>>v[i][j];
    }
   }
   int women = (1<<n)-1;
   dp.resize(n+1,vector<int>(women+1,-1));
   dp[n][0]=1;
   cout<<ways(0,women)<<"\n";

}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Compiler output:
a.cc:4:9: warning: "LONG_LONG_MAX" redefined
    4 | #define LONG_LONG_MAX    9223372036854775807LL
      |         ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38,
                 from a.cc:1:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:154:10: note: this is the location of the previous definition
  154 | # define LONG_LONG_MAX __LONG_LONG_MAX__
      |          ^~~~~~~~~~~~~
a.cc:5:9: warning: "LONG_LONG_MIN" redefined
    5 | #define LONG_LONG_MIN    (-LONG_LONG_MAX-1)
      |         ^~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:152:10: note: this is the location of the previous definition
  152 | # define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
      |          ^~~~~~~~~~~~~
a.cc: In function 'void solve()':
a.cc:32:12: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<bool>::reference')
   32 |         cin>>v[i][j];
      |         ~~~^~~~~~~~~
      |         |          |
      |         |          std::vector<bool>::reference
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
In file included from /usr/include/c++/14/vector:67,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  219 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:219:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |     operator bool() const _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  223 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/14/istream:223:7: note:   conversion of argument 1 would be ill-formed:
a.cc:32:20: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'bool'
   32 |         cin>>v[i][j];
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_bvector.h:99:5: note:   after user-defined conversion: 'std::_Bit_reference::operator bool() const'
   99 |