Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- #ifdef LOCAL
- freopen("in.txt", "r", stdin);
- #else
- freopen("SAMPLE.inp", "r", stdin);
- freopen("SAMPLE.out", "w", stdout);
- #endif // LOCAL
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n, m, k; cin >> n >> m >> k;
- map<int, int> cnt;
- while (n--) {
- string s; cin >> s;
- ++cnt[bitset<20>(s).to_ulong()];
- /*
- int bs = 0;
- for (int i = 0; i < m; ++i)
- bs |= ((s[i] - '0') << i); // (s[i] - '0') dich di i bit
- ++cnt[bs];
- */
- }
- int64_t ans = 0;
- for (int mask1 = 0; mask1 <= (1 << m); ++mask1) {
- for (int mask2 = 0; mask2 <= (1 << m); ++mask2) {
- if (__builtin_popcountll(mask1 ^ mask2) == k) //Dem so bit bat cua (mask1 xor mask2 (giong 0, khac 1))
- ans += cnt[mask1] * cnt[mask2];
- }
- }
- cout << ans / 2 << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment