Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("complementar.in");
- ofstream fout("complementar.out");
- int n, m, p2, a[200005];
- char mat[35];
- long long nr;
- long long xorPairCount(int arr[], int n, int x)
- {
- long long result = 0;
- unordered_map<long long, long long> mp;
- for (int i=0; i<n ; i++)
- {
- int curr_xor = x^arr[i];
- if (mp.find(curr_xor) != mp.end())
- result += mp[curr_xor];
- mp[arr[i]]++;
- }
- return result;
- }
- int main()
- {
- int i;
- fin>>n>>m;
- p2=(1<<m)-1;
- fin.get();
- for(i=0;i<n;i++)
- {
- fin>>mat;
- int dec_value=0;
- int base=1;
- for(int k=m-1;k>=0;k--)
- {
- dec_value+=((int)(mat[k]-'0'))*base;
- base=base*2;
- }
- a[i]=dec_value;
- }
- nr=xorPairCount(a,n,p2);
- fout<<nr;
- return 0;
- }
Add Comment
Please, Sign In to add comment