Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sstream>
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <map>
- #include <stack>
- #include <memory.h>
- #include <queue>
- #include <string>
- #include <string.h>
- #include <cmath>
- #include <utility>
- #include <bitset>
- #include <time.h>
- #include <climits>
- #define PI 3.1415926535897932384626433832795
- #define sqr(x) ((x)*(x))
- #define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
- typedef long long LL;
- typedef unsigned long long ULL;
- using namespace std;
- int d[111111];
- int main(){
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- int n, m;
- LL ans = 0;
- cin >> n >> m;
- for(int i=0;i<n;i++){
- string s;
- int x = 0;
- cin >> s;
- for(int j=0;j<m;j++)
- x = (x<<1) + (s[j] == '+');
- d[x]++;
- }
- int mm = 1 << m;
- for(int i=1; i<mm; ++i) {
- int c = d[0];
- for(int j = (i - 1) & i; j; j = (j - 1) & i) c += d[j];
- ans += (LL)c * d[i];
- }
- cout << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment