Submission #3980783

Source Code Expand

Copy
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 200010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
ll dp[1 << 22];
int mat[23][23];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
      sd(mat[i][j]);
  }
  dp[0] = 1;
  for(int mask = 1; mask < (1 << n) ; mask++)
  {
      for(int j = 0; j < n; j++)
      {
         int ones = __builtin_popcount(mask);
         if(mask & (1 << j)) // can turn off
         {
            int cur = mask ^ (1 << j);
            if(mat[ones - 1][j])
              dp[mask] = (dp[mask] + dp[cur] ) % MOD;
         }
      }
  }
  printf("%lld\n", dp[(1 << n) - 1]);
  return 0;
} 

Submission Info

Submission Time
Task O - Matching
User pulkit96
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1268 Byte
Status
Exec Time 190 ms
Memory 18688 KB

Compile Error

./Main.cpp: In function ‘int main(int, const char**)’:
./Main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   sd(n);
        ^
./Main.cpp:32:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
       sd(mat[i][j]);
                    ^

Test Cases

Set Name Score / Max Score Test Cases
All 100 / 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 1 ms 256 KB
0_01 1 ms 256 KB
0_02 1 ms 256 KB
0_03 187 ms 18688 KB
1_00 1 ms 256 KB
1_01 1 ms 256 KB
1_02 162 ms 256 KB
1_03 165 ms 18688 KB
1_04 173 ms 18688 KB
1_05 178 ms 18688 KB
1_06 187 ms 18688 KB
1_07 182 ms 18688 KB
1_08 187 ms 18688 KB
1_09 190 ms 18688 KB
1_10 182 ms 18688 KB
1_11 180 ms 18688 KB
1_12 180 ms 18688 KB