fork download
  1. //satyaki3794
  2. #include <bits/stdc++.h>
  3. #define pb push_back
  4.  
  5. using namespace std;
  6. typedef long long ll;
  7.  
  8.  
  9. int n, reachable[(1<<14)+2][15];;
  10. vector<int> adj[20];
  11. ll DP[(1<<14)+2][15];
  12.  
  13. int dfs(int mask, int v){
  14.  
  15. int &ans = reachable[mask][v];
  16. if(ans != -1) return ans;
  17.  
  18. ans = (1<<v);
  19. for(auto vv : adj[v]){
  20. if((mask >> vv) & 1) continue;
  21. ans |= dfs(mask|(1<<vv), vv);
  22. }
  23. return ans;
  24. }
  25.  
  26. ll dp(int mask, int v){
  27. ll &ans = DP[mask][v];
  28. if(ans != -1) return ans;
  29. if(reachable[mask][v] == (1<<v)){
  30. return 1;
  31. }
  32. ans = 0;
  33. for(auto vv : adj[v]){
  34. if((mask >> vv) & 1) continue;
  35. ans += dp(mask|(1<<vv), vv) * dp(mask|(reachable[mask|(1<<vv)][vv]), v);
  36. }
  37. return ans;
  38. }
  39.  
  40.  
  41.  
  42. class DFSCount{
  43. public:
  44. ll count(vector<string> G){
  45.  
  46. n = (int)G.size();
  47. for(int i=0;i<n;i++)
  48. for(int j=0;j<n;j++)
  49. if(G[i][j] == 'Y')
  50. adj[i].pb(j);
  51.  
  52.  
  53. memset(reachable, -1, sizeof(reachable));
  54. for(int mask=0;mask<(1<<n);mask++)
  55. for(int i=0;i<n;i++)
  56. if((mask >> i) & 1){
  57. reachable[mask][i] = dfs(mask, i);
  58. }
  59.  
  60. memset(DP, -1, sizeof(DP));
  61. ll ans = 0;
  62. for(int i=0;i<n;i++)
  63. ans += dp((1<<i), i);
  64. return ans;
  65. }
  66. };
  67.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty