fork download
  1. /* In the name of ALLAH, most gracious, most merciful */
  2. #include <bits/stdc++.h>
  3.  
  4.  
  5. using namespace std;
  6. typedef long long ll;
  7. typedef pair< int, int > pi;
  8.  
  9. const int tot = ((1 << 26) - 1);
  10.  
  11. int masks[30];
  12. char s[110];
  13. int n;
  14.  
  15. int solve(int idx, int mask){
  16. if(idx == n){
  17. return (mask == tot);
  18. }
  19. return solve(idx + 1, mask) + solve(idx + 1, mask | masks[idx]);
  20. }
  21.  
  22. int main()
  23. {
  24.  
  25. scanf("%d", &n);
  26.  
  27. for(int i = 0; i < n; i++){
  28. scanf("%s", s);
  29. int l = strlen(s);
  30. for(int j = 0; j < l; j++){
  31. masks[i] |= 1 << (s[j] - 'a');
  32. }
  33. }
  34.  
  35.  
  36. cout << solve(0, 0) << endl;
  37.  
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
0