Language: C++

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define PB emplace_back

using namespace std;

//const int N = 100, NN = 100, LG = 30;
const int N = 2048+100, NN = 2048*1024+100, LG = 30;

long long int dp[N][NN], dp2[N][NN], pw[N], en[NN], mod = 1e9+7;

vector<long long int> v[LG], v2[LG], v3[LG], f[LG];

bool b[LG][LG];

int fun(long long int x) {
    long long int ret = 0;
    while(x!=0) {
        if(x&1)return ret;
        x/=2;
        ret++;
    }
    return 0;
}

int main () {
    for(int i = 0 ; i < 25 ; i++ ) pw[i]=(1LL<<i);
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            cin >> b[i][j];
            if(b[i][j]==1)f[j].PB(i);
        }
    }
    for(int i = 0 ; i < pw[n] ; i++ ) {
        v3[__builtin_popcount(i)].PB(i);
        en[i]=fun(i);
        if(i<pw[(n+1)/2])v2[__builtin_popcount(i)].PB(i);
        if(i<pw[n/2])v[__builtin_popcount(i)].PB(i);
    }
    dp[0][0]=1;
    for(int i = 1 ; i <= n / 2 ; i++ ) {
        for(int u: v[i]) {
            for(int uu: v3[i]) {
                int fix = en[uu];
                for(long long int k: f[fix]) {
                    if(k>=n/2)continue;
                    if(pw[k]&u) {
                        dp[u][uu]+=dp[u-pw[k]][uu-pw[fix]];
                    }
                    dp[u][uu]%=mod;
                }
            }
        }
    }
    dp2[0][0]=1;
    for(int i = 1 ; i <= (n + 1) / 2 ; i++ ) {
        for(int u: v2[i]) {
            for(int uu: v3[i]) {
                int fix = en[uu];
                for(long long int k: f[fix]) {
                    if(k<n/2)continue;
                    int k1 = k - (n/2);
                    if(pw[k1]&u)dp2[u][uu]+=dp2[u-pw[k1]][uu-pw[fix]];
                    dp2[u][uu]%=mod;
                }
            }
        }
    }
    long long int kol = pw[n]-1, ans = 0, f = pw[n/2]-1, s = pw[(n+1)/2]-1;
    for(int i = 0 ; i <= kol ; i++ ) {
        if(__builtin_popcount(i)==n/2) {
            ans+=dp[f][i]*dp2[s][kol^i];
            ans%=mod;
        }
    }
    cout << ans;
}


Compiler output:
/tmp/cc4ZWGL1.o: in function `main':
a.cc:(.text+0x80): relocation truncated to fit: R_X86_64_PC32 against symbol `pw' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x125): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x14d): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x1da): relocation truncated to fit: R_X86_64_PC32 against symbol `v3' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x219): relocation truncated to fit: R_X86_64_PC32 against symbol `en' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x24d): relocation truncated to fit: R_X86_64_PC32 against symbol `pw' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `v2' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x2be): relocation truncated to fit: R_X86_64_PC32 against symbol `pw' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x2ee): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc4ZWGL1.o
a.cc:(.text+0x331): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status