fork download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <iomanip>
  14. #define dibs reserve
  15. #define OVER9000 1234567890
  16. #define patkan 9
  17. #define tisic 47
  18. #define soclose 1e-9
  19. #define pi 3.1415926535898
  20. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  21. #define chocolate win
  22. #define ff first
  23. #define ss second
  24. #define abs(x) ((x < 0)?-(x):(x))
  25. #define uint unsigned int
  26. #include <time.h>
  27. // mylittlepony
  28. using namespace std;
  29.  
  30. int lastone(int x) {return x&(x^(x-1));}
  31.  
  32. int main() {
  33. cin.sync_with_stdio(0);
  34. int N;
  35. cin >> N;
  36. vector<int> W(N,0);
  37. for(int i =0; i < N; i++) {
  38. string s;
  39. vector<int> poc(26,0);
  40. cin >> s;
  41. for(uint j =0; j < s.length(); j++) poc[s[j]-'a']++;
  42. for(int j =0; j < 26; j++) W[i] =(2*W[i]+(int)(poc[j] > 0));}
  43. vector<int> A(1<<15), B(1<<15);
  44. for(int i =0; i < min(12,N); i++) B[1<<i] =W[i];
  45. for(int i =12; i < N; i++) A[1<<(i-12)] =W[i];
  46.  
  47. int ans =0;
  48. for(int i =0; i < (1<<(N-1)); i++) {
  49. int x =0, y =i;
  50. while(y > 0) {
  51. int a =lastone(y);
  52. if((a>>12) > 0) x |=A[a>>12];
  53. else x |=B[a];
  54. y ^=a;}
  55. if(x == (1<<26)-1) ans++;
  56. if((x|W[N-1]) == (1<<26)-1) ans++;}
  57. cout << ans << "\n";
  58. return 0;}
  59.  
  60. // look at my code
  61. // my code is amazing
Runtime error #stdin #stdout #stderr 0s 3432KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc