Submission #3950919


Source Code Expand

Copy
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    const ll MOD = 1e9+7;
    const int N = 1<<22;

    int n;
    int mat[22][22];
    ll dp[22][N];
    vector<int>v[22];

    int main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        cin>>n;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                cin>>mat[i][j];
            }
        }

        dp[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<(1<<n);j++){
                for(int e=0;e<n;e++){
                    if(mat[i][e+1]){
                        int p=(1<<e);
                        if(j&p)dp[i][j]=(dp[i][j]+dp[i-1][j-p])%MOD;
                    }
                }
            }
        }
        cout<<dp[n][(1<<n)-1];
        return 0;
    }

Submission Info

Submission Time
Task O - Matching
User Vasiljko
Language C++14 (GCC 5.4.1)
Score 0
Code Size 858 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 100 0_00, 0_01, 0_02, 0_03, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12
Case Name Status Exec Time Memory
0_00 2 ms 6400 KB
0_01 2 ms 8448 KB
0_02 1 ms 256 KB
0_03 1942 ms 387328 KB
1_00 1 ms 256 KB
1_01 1 ms 2304 KB
1_02 1567 ms 256 KB
1_03 1683 ms 323840 KB
1_04 1678 ms 385280 KB
1_05 1724 ms 387328 KB
1_06 1833 ms 387328 KB
1_07 1950 ms 387328 KB
1_08
1_09
1_10
1_11
1_12