fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long ways[1<<16];
  5. long long mod = 1000000007;
  6.  
  7. long long dp[17][1<<16];
  8. int posCode[16];
  9. int toMask[1<<16];
  10.  
  11. class CampLunch
  12. {
  13. public:
  14. int count(int N, int M, vector <string> a)
  15. {
  16. memset(ways, 0, sizeof(ways));
  17. for(int mask = 0; mask < (1<<(M-1)); mask ++)
  18. if((mask & (mask<<1)) == 0)
  19. {
  20. int x = mask | (mask << 1);
  21. for(int i = 0; i < (1<<M); i++)
  22. if((x & i) == 0)
  23. ways[i] ++;
  24. }
  25. memset(dp, 0, sizeof(dp));
  26. dp[0][0] = 1;
  27. for(int i = 0; i < N; i++)
  28. {
  29. for(int j = 0; j < M; j++)
  30. {
  31. posCode[a[i][j]-'A'] = (1<<j);
  32. }
  33. for(int j = 0; j < (1<<M); j++)
  34. {
  35. toMask[j] = 0;
  36. for(int k = 0; k < M; k++)
  37. if((j & (1<<k)) > 0)
  38. {
  39. toMask[j] += posCode[k];
  40. }
  41. }
  42.  
  43.  
  44. for(int mask = 0; mask < (1<<M); mask ++)
  45. {
  46. if(dp[i][mask] == 0) continue;
  47. dp[i][mask] %= mod;
  48. int remain = (1<<M)-1 - mask;
  49. for(int take = remain; ; take = ((take-1)&remain))
  50. {
  51. dp[i+1][take] += dp[i][mask] * ways[toMask[mask | take]];
  52. //dp[i+1][take] %= mod;
  53. if(take == 0)
  54. break;
  55. }
  56. }
  57. }
  58. return dp[N][0] % mod;
  59. }
  60.  
  61. };
  62.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/4.9/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty