Guest User

Untitled

a guest
May 27th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sstream>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <set>
  8. #include <map>
  9. #include <stack>
  10. #include <memory.h>
  11. #include <queue>
  12. #include <string>
  13. #include <string.h>
  14. #include <cmath>
  15. #include <utility>
  16. #include <bitset>
  17. #include <time.h>
  18. #include <climits>
  19.  
  20. #define PI 3.1415926535897932384626433832795
  21. #define sqr(x) ((x)*(x))
  22. #define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
  23.  
  24. typedef long long LL;
  25. typedef unsigned long long ULL;
  26.  
  27. using namespace std;
  28.  
  29. int d[111111];
  30.  
  31. int main(){
  32. freopen("input.txt","r",stdin);
  33. freopen("output.txt","w",stdout);
  34.  
  35. int n, m;
  36. LL ans = 0;
  37.  
  38. cin >> n >> m;
  39. for(int i=0;i<n;i++){
  40. string s;
  41. int x = 0;
  42.  
  43. cin >> s;
  44. for(int j=0;j<m;j++)
  45. x = (x<<1) + (s[j] == '+');
  46.  
  47. d[x]++;
  48. }
  49.  
  50. int mm = 1 << m;
  51. for(int i=1; i<mm; ++i) {
  52. int c = d[0];
  53. for(int j = (i - 1) & i; j; j = (j - 1) & i) c += d[j];
  54. ans += (LL)c * d[i];
  55. }
  56.  
  57. cout << ans << endl;
  58.  
  59. return 0;
  60. }
Add Comment
Please, Sign In to add comment